module TimeKeeper::StringMinutesSupport
Public Instance Methods
to_i_helper(time)
click to toggle source
# File lib/time_keeper/string_minutes_support.rb, line 10 def to_i_helper(time) return nil if time.blank? time = time.to_s h,m = time.split(":") m ||= "0" raise ArgumentError, "#{time.inspect} is invalid" unless h =~ /^\d+$/ && m =~ /^\d+$/ (h.to_i*60) + m.to_i end
to_s_helper(minutes)
click to toggle source
# File lib/time_keeper/string_minutes_support.rb, line 3 def to_s_helper(minutes) return nil if minutes.nil? h = minutes.to_i / 60 m = minutes.to_i % 60 "%.2d:%.2d" % [h,m] end