Class: Cron2English::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cron2english/all.rb

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



37
38
39
40
41
42
43
44
# File 'lib/cron2english/all.rb', line 37

def initialize
  @dow = nil
  @month = nil
  @dow2num = {}
  @month2num = {}
  @num2dow = {}
  @num2month = {}
end

Instance Method Details

#parse(str) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cron2english/all.rb', line 46

def parse(str)
  str = str.strip

  if str =~ /^@(\w+)$/ and AT_WORDS[$1.downcase]
    process_vixie($1)
  else
    bits = str.split(/[ \t]+/)
    if bits.size == 5
      process_trad(*bits)
    else
      give_up(str)
    end
  end
end