Class: IceCube::SingleOccurrenceRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/ice_cube/single_occurrence_rule.rb

Constant Summary

Constants inherited from Rule

Rule::INTERVAL_TYPES

Instance Attribute Summary collapse

Attributes inherited from Rule

#uses

Instance Method Summary collapse

Methods inherited from Rule

#==, daily, from_hash, from_ical, from_yaml, #hash, hourly, minutely, monthly, #on?, #reset, secondly, #to_ical, #to_yaml, weekly, yearly

Constructor Details

#initialize(time) ⇒ SingleOccurrenceRule

Returns a new instance of SingleOccurrenceRule.


7
8
9
# File 'lib/ice_cube/single_occurrence_rule.rb', line 7

def initialize(time)
  @time = TimeUtil.ensure_time time
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time


5
6
7
# File 'lib/ice_cube/single_occurrence_rule.rb', line 5

def time
  @time
end

Instance Method Details

#full_required?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/ice_cube/single_occurrence_rule.rb', line 26

def full_required?
  false
end

#next_time(t, _, closing_time) ⇒ Object


16
17
18
19
20
# File 'lib/ice_cube/single_occurrence_rule.rb', line 16

def next_time(t, _, closing_time)
  unless closing_time && closing_time < t
    time if time.to_i >= t.to_i
  end
end

#terminating?Boolean

Always terminating

Returns:

  • (Boolean)

12
13
14
# File 'lib/ice_cube/single_occurrence_rule.rb', line 12

def terminating?
  true
end

#to_hashObject


22
23
24
# File 'lib/ice_cube/single_occurrence_rule.rb', line 22

def to_hash
  { :time => time }
end