Class: LS4::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ls4/logic/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nid = 0, address = nil, name = nil, rsids = [], location = nil) ⇒ Node

Returns a new instance of Node.



24
25
26
27
28
29
30
# File 'lib/ls4/logic/node.rb', line 24

def initialize(nid=0, address=nil, name=nil, rsids=[], location=nil)
	@nid = nid
	@address = address
	@name = name
	@rsids = rsids
	@location = location
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



33
34
35
# File 'lib/ls4/logic/node.rb', line 33

def address
  @address
end

#locationObject

Returns the value of attribute location.



36
37
38
# File 'lib/ls4/logic/node.rb', line 36

def location
  @location
end

#nameObject

Returns the value of attribute name.



34
35
36
# File 'lib/ls4/logic/node.rb', line 34

def name
  @name
end

#nidObject (readonly)

Returns the value of attribute nid.



32
33
34
# File 'lib/ls4/logic/node.rb', line 32

def nid
  @nid
end

#rsidsObject

Returns the value of attribute rsids.



35
36
37
# File 'lib/ls4/logic/node.rb', line 35

def rsids
  @rsids
end

Instance Method Details

#==(o) ⇒ Object



46
47
48
49
# File 'lib/ls4/logic/node.rb', line 46

def ==(o)
	# FIXME
	@nid == o.nid && @address == o.address
end

#from_msgpack(obj) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/ls4/logic/node.rb', line 55

def from_msgpack(obj)
	@nid = obj[0]
	@address = Address.load(obj[1])
	@name = obj[2]
	@rsids = obj[3]
	@location = obj[4]
	self
end

#sessionObject



38
39
40
# File 'lib/ls4/logic/node.rb', line 38

def session
	$net.get_session(*@address)
end

#to_msgpack(out = '') ⇒ Object



52
53
54
# File 'lib/ls4/logic/node.rb', line 52

def to_msgpack(out = '')
	[@nid, @address.dump, @name, @rsids, @location].to_msgpack(out)
end

#to_sObject



42
43
44
# File 'lib/ls4/logic/node.rb', line 42

def to_s
	"Node<#{@nid} #{@address} #{@name.dump} #{@rsids.inspect} #{@location.inspect}>"
end