Class: WikiPromoter::TreeNode
- Inherits:
-
Object
- Object
- WikiPromoter::TreeNode
- Defined in:
- lib/wiki_promoter/migrator.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#subdirs ⇒ Object
readonly
Returns the value of attribute subdirs.
Instance Method Summary collapse
- #add_file(path_parts, full_path) ⇒ Object
-
#initialize(name, parent = nil) ⇒ TreeNode
constructor
A new instance of TreeNode.
Constructor Details
#initialize(name, parent = nil) ⇒ TreeNode
Returns a new instance of TreeNode.
10 11 12 13 14 15 |
# File 'lib/wiki_promoter/migrator.rb', line 10 def initialize(name, parent = nil) @name = name @parent = parent @subdirs = {} @files = [] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/wiki_promoter/migrator.rb', line 7 def files @files end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/wiki_promoter/migrator.rb', line 7 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
7 8 9 |
# File 'lib/wiki_promoter/migrator.rb', line 7 def parent @parent end |
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/wiki_promoter/migrator.rb', line 8 def prefix @prefix end |
#subdirs ⇒ Object (readonly)
Returns the value of attribute subdirs.
7 8 9 |
# File 'lib/wiki_promoter/migrator.rb', line 7 def subdirs @subdirs end |
Instance Method Details
#add_file(path_parts, full_path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wiki_promoter/migrator.rb', line 17 def add_file(path_parts, full_path) if path_parts.empty? raise "Empty path parts" elsif path_parts.size == 1 @files << full_path else subdir_name = path_parts.first @subdirs[subdir_name] ||= TreeNode.new(subdir_name, self) @subdirs[subdir_name].add_file(path_parts[1..], full_path) end end |