Class: Avalon::Node

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/avalon/node.rb

Overview

Node is a single object to be monitored It should implement simple interface, only 2 required methods: #poll and #report

Direct Known Subclasses

Btcguild, Eloipool, Internet, Miner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#alarm, #duration, #find_file, #ping, #play, #system

Constructor Details

#initializeNode

Returns a new instance of Node.



16
17
18
# File 'lib/avalon/node.rb', line 16

def initialize
  @data = {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



14
15
16
# File 'lib/avalon/node.rb', line 14

def data
  @data
end

#ipObject (readonly)

Returns the value of attribute ip.



14
15
16
# File 'lib/avalon/node.rb', line 14

def ip
  @ip
end

Class Method Details

.create(monitor, *args) ⇒ Object

Builder method for creating Node subclasses from config arrays



9
10
11
12
# File 'lib/avalon/node.rb', line 9

def Node.create monitor, *args
  subclass = Avalon.const_get(args.first.capitalize)
  subclass.new monitor, *args.drop(1)
end

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

#numObject



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_hashObject



39
40
# File 'lib/avalon/node.rb', line 39

def pool_hash
end

#reportObject

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

#resetObject

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_hashObject

Node API: following methods should be defined:



36
37
# File 'lib/avalon/node.rb', line 36

def unit_hash
end