Class: StatMon::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/stat_mon/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:

  • _self (StatMon::Task)

    the object that the method was called on



6
7
8
# File 'lib/stat_mon/task.rb', line 6

def initialize(&block)
  yield(self) if block_given?
end

Instance Attribute Details

#intervalObject

Returns the value of attribute interval.



4
5
6
# File 'lib/stat_mon/task.rb', line 4

def interval
  @interval
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/stat_mon/task.rb', line 4

def name
  @name
end

#processObject

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

#loggersObject



23
24
25
# File 'lib/stat_mon/task.rb', line 23

def loggers
  @loggers ||= Array.new
end

#valid?Boolean

Returns:

  • (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