Class: Cronscription::Tab

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

Instance Method Summary collapse

Constructor Details

#initialize(cron_lines) ⇒ Tab

Returns a new instance of Tab.



6
7
8
9
# File 'lib/cronscription/tab.rb', line 6

def initialize(cron_lines)
  # Eliminate all lines starting with '#' since they are full comments
  @entries = cron_lines.select{|l| Entry.parsable?(l)}.map{|e| Entry.new(e)}
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
# File 'lib/cronscription/tab.rb', line 11

def ==(other)
  @entries == other.instance_variable_get(:@entries)
end

#find(regex) ⇒ Object



15
16
17
# File 'lib/cronscription/tab.rb', line 15

def find(regex)
  @entries.select{|e| e.match_command?(regex)}
end

#sorted_merge(*arrs) ⇒ Object



19
20
21
# File 'lib/cronscription/tab.rb', line 19

def sorted_merge(*arrs)
  arrs.flatten.uniq.sort
end

#times_to_execute(regex, start, finish) ⇒ Object



23
24
25
# File 'lib/cronscription/tab.rb', line 23

def times_to_execute(regex, start, finish)
  sorted_merge(find(regex).map{|e| e.times_to_execute(start, finish)})
end