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
9 10 11 |
# File 'lib/git_dump/tree/base.rb', line 9 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
15 16 17 18 19 20 |
# File 'lib/git_dump/tree/base.rb', line 15 def each(&block) return to_enum(:each) unless block @entries.each do |_, entry| block[entry] end end |
#each_recursive(&block) ⇒ Object
Iterate over all entries recursively, return enumerator if no block given
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/git_dump/tree/base.rb', line 24 def each_recursive(&block) return to_enum(:each_recursive) unless block @entries.each do |_, entry| if entry.is_a?(Entry) block[entry] else entry.each_recursive(&block) end end end |