Skip to content

Instantly share code, notes, and snippets.

@beaugaines
Created July 24, 2015 16:45
Show Gist options
  • Select an option

  • Save beaugaines/2036b157bf4db952e087 to your computer and use it in GitHub Desktop.

Select an option

Save beaugaines/2036b157bf4db952e087 to your computer and use it in GitHub Desktop.
module ReverseObject
def reverse
case self
when Integer
to_s.reverse.to_i
when Float
to_s.reverse.to_f
end
end
end
class Numeric
include ReverseObject
end
def reverse_it(data)
return data unless %w(String Fixnum Array).include?(data.class.to_s)
data.reverse
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment