Module: TimeKeeper::StringMinutesSupport
- Included in:
- TimeSpanSupport
- Defined in:
- lib/time_keeper/string_minutes_support.rb
Instance Method Summary collapse
Instance Method Details
#to_i_helper(time) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
3 4 5 6 7 8 |
# 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 |