Class: Availability::Daily

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

Direct Known Subclasses

Hourly

Instance Attribute Summary

Attributes inherited from AbstractAvailability

#capacity, #duration, #exclusions, #interval, #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

#interval_difference(this, that) ⇒ Object



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

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

#move_by(time, amount) ⇒ Object



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

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

#residue_for(time) ⇒ Object



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

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