Class: Mappum::MapServer::StrTree
- Defined in:
- lib/mappum/mapserver/mapgraph.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add(child, level = 0) ⇒ Object
-
#initialize(parent, level, root) ⇒ StrTree
constructor
A new instance of StrTree.
- #root ⇒ Object
Constructor Details
#initialize(parent, level, root) ⇒ StrTree
Returns a new instance of StrTree.
167 168 169 170 171 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 167 def initialize(parent, level, root) @parent=parent if level > -1 root << self if level == -1 @parent.add(self, level) unless @parent.nil? end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
166 167 168 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 166 def children @children end |
#line ⇒ Object
Returns the value of attribute line.
166 167 168 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 166 def line @line end |
#name ⇒ Object
Returns the value of attribute name.
166 167 168 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 166 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
166 167 168 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 166 def parent @parent end |
Instance Method Details
#==(other) ⇒ Object
181 182 183 184 185 186 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 181 def ==(other) return false unless other.kind_of?(StrTree) if @line == other.line and @parent == other.parent and @children == other.children return true end end |
#add(child, level = 0) ⇒ Object
173 174 175 176 177 178 179 180 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 173 def add(child, level=0) @children ||= [] if level == 0 @children << child unless @children.include?(child) else @parent.add(child, level - 1) end end |
#root ⇒ Object
187 188 189 190 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 187 def root return parent.root unless parent.nil? return self end |