Class: JPush::Schedule::Trigger
- Inherits:
-
Object
- Object
- JPush::Schedule::Trigger
- Defined in:
- lib/jpush/schedule/trigger.rb
Constant Summary collapse
- WEEK =
['MON','TUE','WED','THU','FRI','SAT','SUN']
- MDAY =
('01'..'31').to_a
Instance Method Summary collapse
- #set_periodical(start_time, end_time, time, time_unit, frequency, point) ⇒ Object
- #set_single(time) ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#set_periodical(start_time, end_time, time, time_unit, frequency, point) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jpush/schedule/trigger.rb', line 14 def set_periodical(start_time, end_time, time, time_unit, frequency, point) @single = nil require 'time' frequency = 100 if frequency > 100 @periodical = { start: start_time.strftime('%F %T'), end: end_time.strftime('%F %T'), time: Time.parse(time).strftime('%T'), time_unit: time_unit, frequency: frequency, point: build_point(time_unit, point) } self end |
#set_single(time) ⇒ Object
8 9 10 11 12 |
# File 'lib/jpush/schedule/trigger.rb', line 8 def set_single(time) @periodical = nil @single = { time: time.strftime('%F %T') } self end |
#to_hash ⇒ Object
29 30 31 32 33 34 |
# File 'lib/jpush/schedule/trigger.rb', line 29 def to_hash @trigger = {} @trigger[:single] = @single unless @single.nil? @trigger[:periodical] = @periodical unless @periodical.nil? @trigger end |