Class: DOTIW::TimeHash
- Inherits:
-
Object
- Object
- DOTIW::TimeHash
- Defined in:
- lib/dotiw/time_hash.rb
Constant Summary collapse
- TIME_FRACTIONS =
[:seconds, :minutes, :hours, :days, :months, :years]
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#from_time ⇒ Object
Returns the value of attribute from_time.
-
#largest ⇒ Object
Returns the value of attribute largest.
-
#smallest ⇒ Object
Returns the value of attribute smallest.
-
#to_time ⇒ Object
Returns the value of attribute to_time.
Instance Method Summary collapse
-
#initialize(distance, from_time = nil, to_time = nil, options = {}) ⇒ TimeHash
constructor
A new instance of TimeHash.
- #to_hash ⇒ Object
Constructor Details
#initialize(distance, from_time = nil, to_time = nil, options = {}) ⇒ TimeHash
Returns a new instance of TimeHash.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dotiw/time_hash.rb', line 9 def initialize(distance, from_time = nil, to_time = nil, = {}) self.output = {} self. = self.distance = distance self.from_time = from_time || Time.now self.to_time = to_time || (self.from_time + self.distance.seconds) self.smallest, self.largest = [self.from_time, self.to_time].minmax I18n.locale = [:locale] if [:locale] build_time_hash end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
7 8 9 |
# File 'lib/dotiw/time_hash.rb', line 7 def distance @distance end |
#from_time ⇒ Object
Returns the value of attribute from_time.
7 8 9 |
# File 'lib/dotiw/time_hash.rb', line 7 def from_time @from_time end |
#largest ⇒ Object
Returns the value of attribute largest.
7 8 9 |
# File 'lib/dotiw/time_hash.rb', line 7 def largest @largest end |
#smallest ⇒ Object
Returns the value of attribute smallest.
7 8 9 |
# File 'lib/dotiw/time_hash.rb', line 7 def smallest @smallest end |
#to_time ⇒ Object
Returns the value of attribute to_time.
7 8 9 |
# File 'lib/dotiw/time_hash.rb', line 7 def to_time @to_time end |
Instance Method Details
#to_hash ⇒ Object
22 23 24 |
# File 'lib/dotiw/time_hash.rb', line 22 def to_hash output end |