Class: GoNodes::NodeList
Class Method Summary collapse
Instance Method Summary collapse
- #==(other_node_list) ⇒ Object
- #[](node_name) ⇒ Object
-
#initialize ⇒ NodeList
constructor
A new instance of NodeList.
- #populate_with_count(node_count) ⇒ Object
- #populate_with_names(node_names) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Set
Constructor Details
Class Method Details
Instance Method Details
#==(other_node_list) ⇒ Object
30 31 32 |
# File 'lib/gonodes/node_list.rb', line 30 def ==(other_node_list) self.sort == other_node_list.sort end |
#[](node_name) ⇒ Object
26 27 28 |
# File 'lib/gonodes/node_list.rb', line 26 def [](node_name) @nodes.select{|node,_| node.name == node_name}.first end |
#populate_with_count(node_count) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/gonodes/node_list.rb', line 34 def populate_with_count(node_count) return unless node_count alpha = "A" @nodes.clear node_count.times do @nodes << Node.new(alpha) alpha = alpha.succ end end |
#populate_with_names(node_names) ⇒ Object
44 45 46 47 48 |
# File 'lib/gonodes/node_list.rb', line 44 def populate_with_names(node_names) return unless node_names @nodes.clear node_names.each { |name| @nodes << Node.new(name)} end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/gonodes/node_list.rb', line 10 def to_s @nodes.to_a.join(", ") end |