Class: Availability::Yearly
- Inherits:
-
AbstractAvailability
- Object
- InstanceVariableComparability
- AbstractAvailability
- Availability::Yearly
- Extended by:
- Createable
- Defined in:
- lib/availability/yearly.rb
Instance Attribute Summary
Attributes inherited from AbstractAvailability
#capacity, #duration, #exclusions, #interval, #residue, #start_time, #stops_by
Instance Method Summary collapse
- #interval_difference(first, second) ⇒ Object
- #move_by(time, amount) ⇒ Object
- #residue_for(time) ⇒ Object
Methods included from Createable
Methods inherited from AbstractAvailability
#beginning, #corresponds_to?, #end_time, #includes?, #initialize, #initialize_copy, #last_occurrence, #next_n_occurrences, #next_occurrence, #time_overlaps?
Methods included from FactoryMethods
Methods included from ClassMethods
#availability?, #beginning, #default_args, #subclass_for
Methods inherited from InstanceVariableComparability
Constructor Details
This class inherits a constructor from Availability::AbstractAvailability
Instance Method Details
#interval_difference(first, second) ⇒ Object
7 8 9 10 |
# File 'lib/availability/yearly.rb', line 7 def interval_difference(first, second) first_date, second_date = [first.to_date, second.to_date].sort second_date.year - first_date.year end |
#move_by(time, amount) ⇒ Object
12 13 14 |
# File 'lib/availability/yearly.rb', line 12 def move_by(time, amount) time + amount.years end |
#residue_for(time) ⇒ Object
16 17 18 19 20 |
# File 'lib/availability/yearly.rb', line 16 def residue_for(time) # date = time.to_date # (date.year - beginning.year).modulo(@interval) interval_difference(beginning, time).modulo(@interval) end |