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.



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

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

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/ice_cube/single_occurrence_rule.rb', line 3

def time
  @time
end

Instance Method Details

#full_required?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ice_cube/single_occurrence_rule.rb', line 24

def full_required?
  false
end

#next_time(t, _, closing_time) ⇒ Object



14
15
16
17
18
# File 'lib/ice_cube/single_occurrence_rule.rb', line 14

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)


10
11
12
# File 'lib/ice_cube/single_occurrence_rule.rb', line 10

def terminating?
  true
end

#to_hashObject



20
21
22
# File 'lib/ice_cube/single_occurrence_rule.rb', line 20

def to_hash
  {time: time}
end