Class: Availability::Weekly

Inherits:
AbstractAvailability show all
Extended by:
Createable
Defined in:
lib/availability/weekly.rb

Instance Attribute Summary

Attributes inherited from AbstractAvailability

#capacity, #duration, #exclusions, #residue, #start_time, #stops_by

Instance Method Summary collapse

Methods included from Createable

create, extended

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

#create, #once

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

#intervalObject



7
8
9
# File 'lib/availability/weekly.rb', line 7

def interval
  @interval * 7
end

#interval_difference(first, second) ⇒ Object



11
12
13
14
# File 'lib/availability/weekly.rb', line 11

def interval_difference(first, second)
  first_date, second_date = [first.to_date, second.to_date].sort
  (second_date - first_date).to_i
end

#move_by(time, amount) ⇒ Object



16
17
18
# File 'lib/availability/weekly.rb', line 16

def move_by(time, amount)
  time + amount.days
end

#residue_for(time) ⇒ Object



20
21
22
# File 'lib/availability/weekly.rb', line 20

def residue_for(time)
  interval_difference(time, beginning).modulo(interval)
end