Class: OpeningTree::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/eco_classifier/opening_tree.rb

Overview

children -> maps move names to more nodes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



13
14
15
# File 'lib/eco_classifier/opening_tree.rb', line 13

def initialize
  @children = {}
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



11
12
13
# File 'lib/eco_classifier/opening_tree.rb', line 11

def children
  @children
end

#openingObject

Returns the value of attribute opening.



11
12
13
# File 'lib/eco_classifier/opening_tree.rb', line 11

def opening
  @opening
end

Instance Method Details

#inspectObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/eco_classifier/opening_tree.rb', line 25

def inspect
  if @opening
    %(
      <Node @eco="#{@opening.eco}"
            @name="#{@opening.name}"
            @n_children=#{@children.size}>
    ).gsub(/\s+/, ' ')
  else
    %(<Node @n_children=#{@children.size}>)
  end
end

#is_leaf?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/eco_classifier/opening_tree.rb', line 21

def is_leaf?
  @children.size == 0
end

#set_opening(opening) ⇒ Object



17
18
19
# File 'lib/eco_classifier/opening_tree.rb', line 17

def set_opening(opening)
  @opening = opening
end