Class: TreeNode

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-editor/ae-editor.rb,
ext/ae-file-history/ae-file-history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, kind = 'KClass') {|_self| ... } ⇒ TreeNode

Returns a new instance of TreeNode.

Yields:

  • (_self)

Yield Parameters:

  • _self (TreeNode)

    the object that the method was called on



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

#helptextObject

Returns the value of attribute helptext.



15
16
17
# File 'ext/ae-editor/ae-editor.rb', line 15

def helptext
  @helptext
end

#kindObject (readonly)

Returns the value of attribute kind.



14
15
16
# File 'ext/ae-editor/ae-editor.rb', line 14

def kind
  @kind
end

#labelObject

Returns the value of attribute label.



15
16
17
# File 'ext/ae-editor/ae-editor.rb', line 15

def label
  @label
end

#parentObject (readonly)

Returns the value of attribute parent.



13
14
15
# File 'ext/ae-editor/ae-editor.rb', line 13

def parent
  @parent
end

#rifObject

Returns the value of attribute rif.



15
16
17
# File 'ext/ae-editor/ae-editor.rb', line 15

def rif
  @rif
end

#sonsObject (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

#pathObject



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