Class: Bahn::ClockTime
- Inherits:
-
Time
- Object
- Time
- Bahn::ClockTime
- Defined in:
- lib/bahn.rb
Overview
Represents a time of day on a 24-hour clock, without implying any particular date.
Class Method Summary collapse
-
.clock(hours, mins) ⇒ Object
Create a new ClockTime object for the time specified by hours and mins.
-
.parse(str) ⇒ Object
Parses a string of the form “hh:mm” and converts it to a ClockTime object.
Instance Method Summary collapse
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
Class Method Details
.clock(hours, mins) ⇒ Object
Create a new ClockTime object for the time specified by hours and mins
14 15 16 |
# File 'lib/bahn.rb', line 14 def self.clock(hours, mins) self.utc(1970, 1, 1, hours, mins, 0) end |
.parse(str) ⇒ Object
Parses a string of the form “hh:mm” and converts it to a ClockTime object
19 20 21 |
# File 'lib/bahn.rb', line 19 def self.parse(str) if str =~ /(\d+):(\d+)/ then self.utc(1970, 1, 1, $1, $2, 0) end end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
23 24 25 |
# File 'lib/bahn.rb', line 23 def inspect # :nodoc: to_s end |
#to_s ⇒ Object
:nodoc:
27 28 29 |
# File 'lib/bahn.rb', line 27 def to_s # :nodoc: sprintf("%02d:%02d", hour, min) end |