Class: TreeNode
- Inherits:
-
Object
- Object
- TreeNode
- Defined in:
- ext/ae-editor/ae-editor.rb,
ext/ae-file-history/ae-file-history.rb
Instance Attribute Summary collapse
-
#helptext ⇒ Object
Returns the value of attribute helptext.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#label ⇒ Object
Returns the value of attribute label.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#rif ⇒ Object
Returns the value of attribute rif.
-
#sons ⇒ Object
readonly
Returns the value of attribute sons.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #dir(_path) ⇒ Object
-
#initialize(parent = nil, kind = 'KClass') {|_self| ... } ⇒ TreeNode
constructor
A new instance of TreeNode.
- #path ⇒ Object
Constructor Details
#initialize(parent = nil, kind = 'KClass') {|_self| ... } ⇒ TreeNode
Returns a new instance of TreeNode.
17 18 19 20 21 22 23 24 25 |
# File 'ext/ae-editor/ae-editor.rb', line 17 def initialize(parent=nil, kind='KClass') @sons = Array.new @parent = parent @kind = kind if @parent !=nil @parent.sons << self end yield(self) if block_given? end |
Instance Attribute Details
#helptext ⇒ Object
Returns the value of attribute helptext.
15 16 17 |
# File 'ext/ae-editor/ae-editor.rb', line 15 def helptext @helptext end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
14 15 16 |
# File 'ext/ae-editor/ae-editor.rb', line 14 def kind @kind end |
#label ⇒ Object
Returns the value of attribute label.
15 16 17 |
# File 'ext/ae-editor/ae-editor.rb', line 15 def label @label end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'ext/ae-editor/ae-editor.rb', line 13 def parent @parent end |
#rif ⇒ Object
Returns the value of attribute rif.
15 16 17 |
# File 'ext/ae-editor/ae-editor.rb', line 15 def rif @rif end |
#sons ⇒ Object (readonly)
Returns the value of attribute sons.
12 13 14 |
# File 'ext/ae-editor/ae-editor.rb', line 12 def sons @sons end |
Instance Method Details
#<=>(other) ⇒ Object
27 28 29 |
# File 'ext/ae-editor/ae-editor.rb', line 27 def <=> (other) self.label.strip <=> other.label.strip end |
#dir(_path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'ext/ae-file-history/ae-file-history.rb', line 36 def dir(_path) node = nil parent = self sons.each{|_tree| if _path[0.._tree.label.length-1] == _tree.label res = _path[_tree.label.length.._path.length-1] if ["\\","/"].include?(res[0,1]) parent = _tree node= _tree.dir(res) end end break if node != nil } if node == nil node = TreeNode.new(parent,'KDir') do |_node| _node.label=_path _node.rif= parent.path+_path end end return node end |
#path ⇒ Object
28 29 30 31 32 33 34 |
# File 'ext/ae-file-history/ae-file-history.rb', line 28 def path _path = @label if @parent != nil _path = @parent.path+_path end return _path end |