Skip to content

Instantly share code, notes, and snippets.

@mzaragoza
Created September 9, 2013 21:48
Show Gist options
  • Save mzaragoza/6501997 to your computer and use it in GitHub Desktop.
Save mzaragoza/6501997 to your computer and use it in GitHub Desktop.
config/initializers/strings.rb
class String
def map(arg=nil)
if arg
[self].map(arg)
elsif block_given?
[self].map{|i| yield(i)}
else
[self]
end
end
def cycle(num)
to_a.cycle(num)
end
def to_a
self.split('')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment