Class: ChronicCron

Inherits:
Object
  • Object
show all
Includes:
AppRoutes
Defined in:
lib/chronic_cron.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s, now = Time.now) ⇒ ChronicCron

Returns a new instance of ChronicCron.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chronic_cron.rb', line 16

def initialize(s, now=Time.now)
  
  @now = now
  
  super()
  @params = {input: s}
  expressions(@params)

  expression = find_expression(s.downcase\
                               .sub(/^(?:on|at|from|starting)\s+/,''))
  #puts 'expression : ' + expression.inspect
  @cf = CronFormat.new(expression, now)
  @to_expression = @cf.to_expression

end

Instance Attribute Details

#to_expressionObject (readonly)

Returns the value of attribute to_expression.



14
15
16
# File 'lib/chronic_cron.rb', line 14

def to_expression
  @to_expression
end

Instance Method Details

#in24hrs(raw_hrs, meridiem) ⇒ Object



297
298
299
300
301
302
303
304
# File 'lib/chronic_cron.rb', line 297

def in24hrs(raw_hrs, meridiem)

  hrs = if meridiem == 'pm' then
    raw_hrs.to_i + 12
  else
    raw_hrs.to_i == 12 ? 0 : raw_hrs
  end
end

#inspectObject



32
33
34
35
# File 'lib/chronic_cron.rb', line 32

def inspect() 
  "#<ChronicCron:%s @to_expression=\"%s\", @to_time=\"%s\">" % 
      [self.object_id, @to_expression, @cf.to_time]
end

#nextObject



37
38
39
# File 'lib/chronic_cron.rb', line 37

def next()
  @cf.next
end

#to_dateObject



41
42
43
# File 'lib/chronic_cron.rb', line 41

def to_date() 
  @cf.to_time.to_date
end

#to_timeObject



45
46
47
# File 'lib/chronic_cron.rb', line 45

def to_time()
  @cf.to_time
end