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
15 16 17 |
# File 'lib/bahn.rb', line 15 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
20 21 22 |
# File 'lib/bahn.rb', line 20 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:
24 25 26 |
# File 'lib/bahn.rb', line 24 def inspect # :nodoc: to_s end |
#to_s ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/bahn.rb', line 28 def to_s # :nodoc: sprintf("%02d:%02d", hour, min) end |