Class: Avalon::Node
Overview
Node is a single object to be monitored It should implement simple interface, only 2 required methods: #poll and #report
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
Class Method Summary collapse
-
.create(monitor, *args) ⇒ Object
Builder method for creating Node subclasses from config arrays.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get a specific data point about this Node.
-
#[]=(key, value) ⇒ Object
Set a specific data point.
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #num ⇒ Object
-
#poll(verbose) ⇒ Object
Abstract: Check node status If verbose, the Node should print out its state after the status update.
- #pool_hash ⇒ Object
-
#report ⇒ Object
Abstract: Report node errors or special situations (if any).
-
#reset ⇒ Object
Abstract: Reset or reboot node.
-
#unit_hash ⇒ Object
Node API: following methods should be defined:.
Methods included from Utils
#alarm, #duration, #find_file, #ping, #play, #system
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
16 17 18 |
# File 'lib/avalon/node.rb', line 16 def initialize @data = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/avalon/node.rb', line 14 def data @data end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
14 15 16 |
# File 'lib/avalon/node.rb', line 14 def ip @ip end |
Class Method Details
Instance Method Details
#[](key) ⇒ Object
Get a specific data point about this Node
25 26 27 |
# File 'lib/avalon/node.rb', line 25 def [] key @data[key] end |
#[]=(key, value) ⇒ Object
Set a specific data point
30 31 32 |
# File 'lib/avalon/node.rb', line 30 def []= key, value @data[key] = value end |
#num ⇒ Object
20 21 22 |
# File 'lib/avalon/node.rb', line 20 def num @num ||= @ip ? @ip.split('.').last.to_i : "" end |
#poll(verbose) ⇒ Object
Abstract: Check node status If verbose, the Node should print out its state after the status update
44 45 46 |
# File 'lib/avalon/node.rb', line 44 def poll verbose raise "#{self.class} should implement #poll" end |
#pool_hash ⇒ Object
39 40 |
# File 'lib/avalon/node.rb', line 39 def pool_hash end |
#report ⇒ Object
Abstract: Report node errors or special situations (if any)
49 50 51 |
# File 'lib/avalon/node.rb', line 49 def report raise "#{self.class} should implement #report" end |
#reset ⇒ Object
Abstract: Reset or reboot node
54 55 56 |
# File 'lib/avalon/node.rb', line 54 def reset raise "#{self.class} should implement #report" end |
#unit_hash ⇒ Object
Node API: following methods should be defined:
36 37 |
# File 'lib/avalon/node.rb', line 36 def unit_hash end |