Skip to content

Instantly share code, notes, and snippets.

@taq
Created December 26, 2013 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taq/8133050 to your computer and use it in GitHub Desktop.
Save taq/8133050 to your computer and use it in GitHub Desktop.
Ruby 2.1 refinements
module TimeExtensions
refine Fixnum do
def min2sec; self * 60; end
end
end
class Minutes
using TimeExtensions
def self.to_sec(min)
min.min2sec
end
end
puts Minutes.to_sec(2) # => 120
puts 2.min2sec # => NoMethodError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment