Reputation: 13497
I am putting this code into a wrapper class and therefore need all helper methods to be static. Everything is working besides my seconds method. How do I alias :seconds to a static method?
def self.minutes
(rand(58) + 1).to_s
end
def self.hours
(rand(22) + 1).to_s
end
alias :seconds :minutes
Upvotes: 3
Views: 905
Reputation: 51151
Static methods are really instance methods of class's eigenclass, so you can do:
class << self
def minutes
(rand(58) + 1).to_s
end
def hours
(rand(22) + 1).to_s
end
alias :seconds :minutes
end
Upvotes: 7