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.
-
#rif_end ⇒ Object
Returns the value of attribute rif_end.
-
#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.
Constructor Details
#initialize(parent = nil, kind = 'KClass') {|_self| ... } ⇒ TreeNode
Returns a new instance of TreeNode.
21 22 23 24 25 26 27 28 29 |
# File 'ext/ae-editor/ae-editor.rb', line 21 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.
19 20 21 |
# File 'ext/ae-editor/ae-editor.rb', line 19 def helptext @helptext end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
18 19 20 |
# File 'ext/ae-editor/ae-editor.rb', line 18 def kind @kind end |
#label ⇒ Object
Returns the value of attribute label.
19 20 21 |
# File 'ext/ae-editor/ae-editor.rb', line 19 def label @label end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
17 18 19 |
# File 'ext/ae-editor/ae-editor.rb', line 17 def parent @parent end |
#rif ⇒ Object
Returns the value of attribute rif.
19 20 21 |
# File 'ext/ae-editor/ae-editor.rb', line 19 def rif @rif end |
#rif_end ⇒ Object
Returns the value of attribute rif_end.
19 20 21 |
# File 'ext/ae-editor/ae-editor.rb', line 19 def rif_end @rif_end end |
#sons ⇒ Object (readonly)
Returns the value of attribute sons.
16 17 18 |
# File 'ext/ae-editor/ae-editor.rb', line 16 def sons @sons end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 |
# File 'ext/ae-editor/ae-editor.rb', line 31 def <=> (other) self.label.strip <=> other.label.strip end |
#dir(_path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'ext/ae-file-history/ae-file-history.rb', line 33 def dir(_path) node = nil parent = self sons.each{|_tree| ["\\","/"].include?(_path[0,1])?_index = 1:_index=0 if _path[_index.._tree.label.length-1+_index] == _tree.label res = _path[_tree.label.length+_index.._path.length-1] if ["\\","/"].include?(res[0,1]) parent = _tree node= _tree.dir(res) end end break if node != nil } if node == nil if _path == '/' || _path == '\\' # ok -- we have the root elsif _path.length > 0 && (_path.include?("/")||_path.include?("\\")) _path.include?("/")?_sep="/":_sep="\\" _parent_length = _path.length - _path.split(_sep)[-1].length _parent_path = _path[0.._parent_length-2] if _parent_path != _path parent = parent.dir(_parent_path) _path = _path[_parent_length-1.._path.length-1] end end node = TreeNode.new(parent,'KDir') do |_node| _node.label=_path if ["\\","/"].include?(_node.label[0,1]) _node.label = _node.label[1..-1] end parent.rif == "root"?parent_rif = "":parent_rif=parent.rif _node.rif= (parent_rif+_path).sub(":",'%%%') end end return node end |