Class: TimeSpanner::TimeUnits::CalendarUnit
- Defined in:
- lib/time_spanner/time_units/base/calendar_unit.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Unit
#amount, #duration, #position, #rest
Instance Method Summary collapse
- #calculate(duration, to) ⇒ Object
-
#initialize(position) ⇒ CalendarUnit
constructor
A new instance of CalendarUnit.
Methods inherited from Unit
Constructor Details
#initialize(position) ⇒ CalendarUnit
Returns a new instance of CalendarUnit.
8 9 10 |
# File 'lib/time_spanner/time_units/base/calendar_unit.rb', line 8 def initialize position super position end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/time_spanner/time_units/base/calendar_unit.rb', line 6 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/time_spanner/time_units/base/calendar_unit.rb', line 6 def to @to end |
Instance Method Details
#calculate(duration, to) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/time_spanner/time_units/base/calendar_unit.rb', line 12 def calculate duration, to @to = to @from = @to - duration.to_r calculate_amount calculate_rest at_amount( amount ) end |