Class: ChronicCron
Instance Attribute Summary collapse
-
#to_expression ⇒ Object
readonly
Returns the value of attribute to_expression.
Instance Method Summary collapse
- #in24hrs(raw_hrs, meridiem) ⇒ Object
-
#initialize(s, now = Time.now) ⇒ ChronicCron
constructor
A new instance of ChronicCron.
- #inspect ⇒ Object
- #next ⇒ Object
- #to_date ⇒ Object
- #to_time ⇒ Object
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_expression ⇒ Object (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 |
#inspect ⇒ Object
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 |
#next ⇒ Object
37 38 39 |
# File 'lib/chronic_cron.rb', line 37 def next() @cf.next end |
#to_date ⇒ Object
41 42 43 |
# File 'lib/chronic_cron.rb', line 41 def to_date() @cf.to_time.to_date end |
#to_time ⇒ Object
45 46 47 |
# File 'lib/chronic_cron.rb', line 45 def to_time() @cf.to_time end |