Class: Availability::Once
- Inherits:
-
AbstractAvailability
- Object
- AbstractAvailability
- Availability::Once
- Extended by:
- Createable
- Defined in:
- lib/availability/once.rb
Instance Attribute Summary
Attributes inherited from AbstractAvailability
#capacity, #duration, #exclusions, #interval, #residue, #start_time, #stops_by
Instance Method Summary collapse
-
#initialize(**args) ⇒ Once
constructor
A new instance of Once.
- #interval_difference(this, that) ⇒ Object
- #last_occurrence ⇒ Object
- #move_by(time, amount) ⇒ Object
- #residue_for(time) ⇒ Object
Methods included from Createable
Methods inherited from AbstractAvailability
#beginning, #corresponds_to?, #end_time, #initialize_copy, #next_n_occurrences, #next_occurrence, #occurs_at?, #time_overlaps?
Methods included from FactoryMethods
Methods included from ClassMethods
#availability?, #beginning, #default_args, #subclass_for
Constructor Details
#initialize(**args) ⇒ Once
Returns a new instance of Once.
7 8 9 10 11 |
# File 'lib/availability/once.rb', line 7 def initialize(**args) raise ArgumentError, "start_time is required" unless args.has_key?(:start_time) raise ArgumentError, "duration is required" unless args.has_key?(:duration) super **args, interval: 0, stops_by: args[:start_time] + args[:duration] end |
Instance Method Details
#interval_difference(this, that) ⇒ Object
13 14 15 |
# File 'lib/availability/once.rb', line 13 def interval_difference(this, that) raise NotImplementedError.new('not supported') end |
#last_occurrence ⇒ Object
21 22 23 |
# File 'lib/availability/once.rb', line 21 def last_occurrence start_time end |
#move_by(time, amount) ⇒ Object
17 18 19 |
# File 'lib/availability/once.rb', line 17 def move_by(time, amount) time + amount.days end |
#residue_for(time) ⇒ Object
25 26 27 |
# File 'lib/availability/once.rb', line 25 def residue_for(time) 0 end |