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.



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

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.



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

def data
  @data
end

Instance Method Details

#[](symbol, *args) ⇒ Object



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

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

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



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

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

#include?(symbol) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#saveObject



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

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