Module: GitDump::Tree::Base
- Included in:
- GitDump::Tree, Builder
- Defined in:
- lib/git_dump/tree/base.rb
Overview
Common methods in Tree and Builder
Instance Method Summary collapse
-
#[](path) ⇒ Object
Retrive tree or entry at path, return nil if there is nothing at path.
-
#each(&block) ⇒ Object
Iterate over every tree/entry of this tree, return enumerator if no block given.
-
#each_recursive(&block) ⇒ Object
Iterate over all entries recursively, return enumerator if no block given.
Instance Method Details
#[](path) ⇒ Object
Retrive tree or entry at path, return nil if there is nothing at path
11 12 13 |
# File 'lib/git_dump/tree/base.rb', line 11 def [](path) get_at(parse_path(path)) end |
#each(&block) ⇒ Object
Iterate over every tree/entry of this tree, return enumerator if no block given
17 18 19 20 21 22 23 |
# File 'lib/git_dump/tree/base.rb', line 17 def each(&block) return to_enum(:each) unless block @entries.each_value do |entry| block[entry] end end |
#each_recursive(&block) ⇒ Object
Iterate over all entries recursively, return enumerator if no block given
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/git_dump/tree/base.rb', line 27 def each_recursive(&block) return to_enum(:each_recursive) unless block @entries.each_value do |entry| if entry.is_a?(Entry) block[entry] else entry.each_recursive(&block) end end end |