-
-
Save leejarvis/04437cbff195ec495886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Truncate | |
refine String do | |
def truncate(n: 100) | |
self[0...n] | |
end | |
end | |
end | |
class Foo | |
using Truncate | |
def foo | |
something.truncate | |
end | |
def bar | |
something.truncate | |
end | |
def baz | |
something.truncate | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def foo | |
truncate something | |
end | |
def bar | |
truncate something | |
end | |
def baz | |
truncate something | |
end | |
private | |
def truncate(v, n: 100) | |
v[0...n] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment