Class: Flounder::Result::Accessor::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/flounder/result/accessor/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



8
9
10
11
12
# File 'lib/flounder/result/accessor/node.rb', line 8

def initialize 
  @children_by_name = Hash.new do |hash, name|
    hash[name.to_sym] = Node.new
  end
end

Instance Attribute Details

#children_by_nameObject (readonly)

Returns the value of attribute children_by_name.



6
7
8
# File 'lib/flounder/result/accessor/node.rb', line 6

def children_by_name
  @children_by_name
end

Instance Method Details

#[](name) ⇒ Object



14
15
16
# File 'lib/flounder/result/accessor/node.rb', line 14

def [] name
  children_by_name[name.to_sym]
end

#add_field(name, *a) ⇒ Object



24
25
26
# File 'lib/flounder/result/accessor/node.rb', line 24

def add_field name, *a
  children_by_name[name.to_sym] = Field.new(*a)
end

#has_obj?(name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/flounder/result/accessor/node.rb', line 17

def has_obj? name
  children_by_name.has_key? name.to_sym
end

#namesObject



20
21
22
# File 'lib/flounder/result/accessor/node.rb', line 20

def names
  children_by_name.keys
end

#produce_value(*_) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



32
33
34
# File 'lib/flounder/result/accessor/node.rb', line 32

def produce_value *_
  yield self
end

#sizeObject



28
29
30
# File 'lib/flounder/result/accessor/node.rb', line 28

def size
  children_by_name.size
end