Class: TimeSpanner::TimeSpan

Inherits:
Hash
  • Object
show all
Includes:
Errors
Defined in:
lib/time_spanner/time_span.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, unit_names = []) ⇒ TimeSpan

Returns a new instance of TimeSpan.



8
9
10
11
12
13
14
15
# File 'lib/time_spanner/time_span.rb', line 8

def initialize from, to, unit_names = []
  validate! from, to

  units       = TimeUnitCollector.new( unit_names ).units
  @unit_chain = DurationChain.new from.to_time, to.to_time, units

  build!
end

Instance Attribute Details

#unit_chainObject (readonly)

Returns the value of attribute unit_chain.



6
7
8
# File 'lib/time_spanner/time_span.rb', line 6

def unit_chain
  @unit_chain
end