Class: CrontabParser

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/crontab-parser.rb,
lib/crontab-parser/record.rb,
lib/crontab-parser/time_parser.rb

Defined Under Namespace

Classes: Record, TimeParser

Instance Method Summary collapse

Constructor Details

#initialize(crontab, options = {}) ⇒ CrontabParser

Returns a new instance of CrontabParser.



10
11
12
13
# File 'lib/crontab-parser.rb', line 10

def initialize(crontab, options={})
  @crontab = crontab
  @options = options
end

Instance Method Details

#eachObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/crontab-parser.rb', line 15

def each
  io = if File.exists?(@crontab)
    open(@crontab, 'r')
  else
    StringIO.new(@crontab)
  end
  until io.eof?
    line = io.gets
    line.strip!
    if line.length > 0 && line.index('#') != 0
      yield Record.new(line, @options) 
    end
  end
end