Class: Biosphere::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_string = nil) ⇒ Node

Returns a new instance of Node.



7
8
9
10
11
12
13
14
# File 'lib/biosphere/node.rb', line 7

def initialize(from_string = nil)
    if from_string
        blob = Marshal.load(from_string)
        @data = blob.data
    else
        @data = {}
    end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/biosphere/node.rb', line 6

def data
  @data
end

Instance Method Details

#[](symbol, *args) ⇒ Object



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

def [](symbol, *args)
    if !@data[symbol]
        @data[symbol] = Node.new
    end
    return @data[symbol]
end

#[]=(symbol, *args) ⇒ Object



20
21
22
# File 'lib/biosphere/node.rb', line 20

def []=(symbol, *args)
    @data[symbol] = args[0]
end

#include?(symbol) ⇒ Boolean

Returns:

  • (Boolean)


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

def include?(symbol)
    @data.include?(symbol)
end

#saveObject



31
32
33
# File 'lib/biosphere/node.rb', line 31

def save()
    return Marshal.dump(self)
end

#valuesObject



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

def values
    return @data.values
end