Class CronEdit::CronEntry
In: lib/cronedit.rb
Parent: Object

A cron entry …

Methods

[]   new   to_hash   to_raw   to_s  

Classes and Modules

Class CronEdit::CronEntry::FormatError

Constants

DEFAULTS = { :minute => '*', :hour => '*', :day => '*', :month => '*', :weekday => '*', :command => ''
WDAY = %w(sun mon tue wed thu fri sut)

Public Class methods

Hash def, or raw String def

[Source]

     # File lib/cronedit.rb, line 421
421:         def initialize aDef = {}
422:             if aDef.kind_of? Hash  
423:                 wrong = aDef.collect { |k,v| DEFAULTS.include?(k) ? nil : k}.compact
424:                 raise "Wrong definition, invalid constructs #{wrong}" unless wrong.empty?
425:                 @defHash = DEFAULTS.merge aDef
426:                 # TODO: validate values
427:                 @def = to_raw @defHash ;
428:             else
429:                 @defHash = parseTextDef aDef
430:                 @def = aDef;
431:             end
432:         end

Public Instance methods

[Source]

     # File lib/cronedit.rb, line 442
442:         def []aField
443:             @defHash[aField]
444:         end

[Source]

     # File lib/cronedit.rb, line 438
438:         def to_hash
439:             @defHash.freeze
440:         end

[Source]

     # File lib/cronedit.rb, line 446
446:         def to_raw aHash = nil;
447:             aHash ||= @defHash
448:             "#{aHash[:minute]}\t#{aHash[:hour]}\t#{aHash[:day]}\t#{aHash[:month]}\t"  +
449:                 "#{aHash[:weekday]}\t#{aHash[:command]}"
450:         end

[Source]

     # File lib/cronedit.rb, line 434
434:         def to_s
435:             @def.freeze
436:         end

[Validate]