Created
December 26, 2013 12:15
-
-
Save taq/8133050 to your computer and use it in GitHub Desktop.
Ruby 2.1 refinements
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 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