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.
166 167 168 169 170 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 166 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.
165 166 167 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 165 def children @children end |
#line ⇒ Object
Returns the value of attribute line.
165 166 167 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 165 def line @line end |
#name ⇒ Object
Returns the value of attribute name.
165 166 167 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 165 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
165 166 167 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 165 def parent @parent end |
Instance Method Details
#==(other) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 180 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
172 173 174 175 176 177 178 179 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 172 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
186 187 188 189 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 186 def root return parent.root unless parent.nil? return self end |