Class: Availability::Monthly
- Inherits:
-
AbstractAvailability
- Object
- InstanceVariableComparability
- AbstractAvailability
- Availability::Monthly
- Extended by:
- Createable
- Defined in:
- lib/availability/monthly.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/monthly.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) * 12 + (second_date.month - first_date.month) end |
#move_by(time, amount) ⇒ Object
12 13 14 |
# File 'lib/availability/monthly.rb', line 12 def move_by(time, amount) time + amount.months end |
#residue_for(time) ⇒ Object
16 17 18 |
# File 'lib/availability/monthly.rb', line 16 def residue_for(time) interval_difference(beginning, time).modulo(@interval) end |