Class: StatMon::Task
- Inherits:
-
Object
- Object
- StatMon::Task
- Defined in:
- lib/stat_mon/task.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#name ⇒ Object
Returns the value of attribute name.
-
#process ⇒ Object
Returns the value of attribute process.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Task
constructor
A new instance of Task.
- #log(msg) ⇒ Object
- #logger(opts) ⇒ Object
- #loggers ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize {|_self| ... } ⇒ Task
Returns a new instance of Task.
6 7 8 |
# File 'lib/stat_mon/task.rb', line 6 def initialize(&block) yield(self) if block_given? end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
4 5 6 |
# File 'lib/stat_mon/task.rb', line 4 def interval @interval end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/stat_mon/task.rb', line 4 def name @name end |
#process ⇒ Object
Returns the value of attribute process.
4 5 6 |
# File 'lib/stat_mon/task.rb', line 4 def process @process end |
Instance Method Details
#log(msg) ⇒ Object
17 18 19 20 21 |
# File 'lib/stat_mon/task.rb', line 17 def log( msg ) loggers.each do |logger| logger.info( msg ) end end |
#logger(opts) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/stat_mon/task.rb', line 27 def logger( opts ) logger = nil if opts.has_key?(:file) logger = Log.new( opts[:file] ) end loggers << logger if logger end |
#loggers ⇒ Object
23 24 25 |
# File 'lib/stat_mon/task.rb', line 23 def loggers @loggers ||= Array.new end |
#valid? ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/stat_mon/task.rb', line 10 def valid? valid = true valid = false if self.name.nil? valid = false if self.process.nil? valid end |