Class: DBI::Time
- Inherits:
-
Object
- Object
- DBI::Time
- Defined in:
- lib/dbi/utils/time.rb
Overview
Represents a Time
DEPRECATED: Please use a regular Time or DateTime object.
Instance Attribute Summary collapse
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#minute ⇒ Object
(also: #min)
Returns the value of attribute minute.
-
#second ⇒ Object
(also: #sec)
Returns the value of attribute second.
Instance Method Summary collapse
-
#to_s ⇒ Object
Returns a DBI::Time object as a string in HH:MM:SS format.
-
#to_time ⇒ Object
Returns a new Time object based on the hour, minute and second, using the current year, month and day.
Instance Attribute Details
#hour ⇒ Object
Returns the value of attribute hour.
7 8 9 |
# File 'lib/dbi/utils/time.rb', line 7 def hour @hour end |
#minute ⇒ Object Also known as: min
Returns the value of attribute minute.
7 8 9 |
# File 'lib/dbi/utils/time.rb', line 7 def minute @minute end |
#second ⇒ Object Also known as: sec
Returns the value of attribute second.
7 8 9 |
# File 'lib/dbi/utils/time.rb', line 7 def second @second end |
Instance Method Details
#to_s ⇒ Object
Returns a DBI::Time object as a string in HH:MM:SS format.
48 49 50 |
# File 'lib/dbi/utils/time.rb', line 48 def to_s sprintf("%02d:%02d:%02d", @hour, @minute, @second) end |
#to_time ⇒ Object
Returns a new Time object based on the hour, minute and second, using the current year, month and day. If a Time object was passed to the constructor, returns that object instead.
38 39 40 41 42 43 44 45 |
# File 'lib/dbi/utils/time.rb', line 38 def to_time if @original_time @original_time else t = ::Time.now ::Time.local(t.year, t.month, t.day, @hour, @minute, @second) end end |