Class: Gitcopier::DirTreeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/gitcopier/dir_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DirTreeNode

Returns a new instance of DirTreeNode.



49
50
51
52
53
# File 'lib/gitcopier/dir_tree.rb', line 49

def initialize(path)
  @path = path
  @type = path.end_with?('/') ? 'dir' : 'file'
  @children = {}
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



47
48
49
# File 'lib/gitcopier/dir_tree.rb', line 47

def children
  @children
end

#pathObject

Returns the value of attribute path.



47
48
49
# File 'lib/gitcopier/dir_tree.rb', line 47

def path
  @path
end

#typeObject

Returns the value of attribute type.



47
48
49
# File 'lib/gitcopier/dir_tree.rb', line 47

def type
  @type
end

Instance Method Details

#add_child(name, path) ⇒ Object

add or replace a child with given name and path



60
61
62
63
64
# File 'lib/gitcopier/dir_tree.rb', line 60

def add_child(name, path)
  child = DirTreeNode.new(path)
  @children[name] = child
  return child
end

#get_child(name) ⇒ Object



55
56
57
# File 'lib/gitcopier/dir_tree.rb', line 55

def get_child(name)
  @children[name]
end