class Graal::Tree
Public Instance Methods
blobs(&block)
click to toggle source
# File lib/graal/tree.rb, line 30 def blobs(&block) enum_children(:blobs, 'blob', &block) end
Also aliased as: each_blob, list_blobs
child(child_path)
click to toggle source
# File lib/graal/tree.rb, line 7 def child(child_path) fullpath = File.join(@path, child_path) fullpath[ 0] = '' if fullpath[ 0] == ?/ fullpath[-1] = '' if fullpath[-1] == ?/ type, child_gitid = @backend.child(gitid, fullpath) child_for(type, fullpath, child_gitid) end
children(&block)
click to toggle source
# File lib/graal/tree.rb, line 17 def children(&block) enum_children(:children, &block) end
trees(&block)
click to toggle source
# File lib/graal/tree.rb, line 24 def trees(&block) enum_children(:trees, 'tree', &block) end
Also aliased as: each_tree, list_trees
Private Instance Methods
child_for(type, fullpath, gitid)
click to toggle source
# File lib/graal/tree.rb, line 46 def child_for(type, fullpath, gitid) return Blob.new(@backend, @revision, fullpath, gitid) if type == 'blob' Tree.new(@backend, @revision, fullpath, gitid) end
enum_children(method, filter = nil) { |child_for(*data)| ... }
click to toggle source
# File lib/graal/tree.rb, line 38 def enum_children(method, filter = nil) dirpath = @path.empty? ? path : path + '/' @backend.children(gitid, dirpath, filter).each do |data| yield child_for(*data) end if block_given? Enumerator.new(self, method) end