Class: Cronin::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Parser

Returns a new instance of Parser.



3
4
5
# File 'lib/cronin/parser.rb', line 3

def initialize(entry)
  @entry = entry
end

Instance Method Details

#parseObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/cronin/parser.rb', line 7

def parse
  splited = @entry.split[0..4]
  klasses = [Minutes, Hours, MonthDays, Months, WeekDays]
  keys    = [:minutes, :hours, :month_days, :months, :week_days]
  result = {}
  splited.each_with_index do |entry,i|
    result[keys[i]] = klasses[i].new(entry)
  end
  result
end