Class: CronWTF::Entry
- Inherits:
-
Object
- Object
- CronWTF::Entry
- Defined in:
- lib/rcronwtf/entry.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#is_comment ⇒ Object
readonly
Returns the value of attribute is_comment.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#week_days ⇒ Object
readonly
Returns the value of attribute week_days.
Instance Method Summary collapse
-
#initialize(entry) ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
Constructor Details
#initialize(entry) ⇒ Entry
Returns a new instance of Entry.
4 5 6 7 8 |
# File 'lib/rcronwtf/entry.rb', line 4 def initialize(entry) @is_comment = (entry.nil? or entry.strip.empty? or entry.match /^#/) ? true : false @entry = entry.strip.gsub(/\s+/, " ") parse unless is_comment end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def command @command end |
#days ⇒ Object (readonly)
Returns the value of attribute days.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def days @days end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def hours @hours end |
#is_comment ⇒ Object (readonly)
Returns the value of attribute is_comment.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def is_comment @is_comment end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def minutes @minutes end |
#months ⇒ Object (readonly)
Returns the value of attribute months.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def months @months end |
#week_days ⇒ Object (readonly)
Returns the value of attribute week_days.
2 3 4 |
# File 'lib/rcronwtf/entry.rb', line 2 def week_days @week_days end |
Instance Method Details
#to_s ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rcronwtf/entry.rb', line 10 def to_s return @entry if is_comment msg = [] %w(minute hour day month week_day).each do |attribute| key = (attribute + "s") prev = msg[msg.length - 1] values = self.send(key) if(values == '*') if(!prev || !prev.match(/^every/)) msg << "every #{attribute.gsub('_', ' ')}" end else msg << send("#{key}_message", values) end end "Runs `#{@command}` #{msg.join(', ')}." end |