Method: Rugged::Tree#each
- Defined in:
- ext/rugged/rugged_tree.c
#each {|entry| ... } ⇒ Object #each ⇒ Object
Call block with each of the entries of the subtree as a Hash. If no block is given, an enumerator is returned instead.
Note that only the entries in the root of the tree are yielded; if you need to list also entries in subfolders, use tree.walk instead.
tree.each { |entry| puts entry.inspect }
generates:
{:name => "foo.txt", :type => :blob, :oid => "d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f", :filemode => 0}
{:name => "bar.txt", :type => :blob, :oid => "de5ba987198bcf2518885f0fc1350e5172cded78", :filemode => 0}
...
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'ext/rugged/rugged_tree.c', line 221
static VALUE rb_git_tree_each(VALUE self)
{
git_tree *tree;
size_t i, count;
RETURN_ENUMERATOR(self, 0, 0);
TypedData_Get_Struct(self, git_tree, &rugged_object_type, tree);
count = git_tree_entrycount(tree);
for (i = 0; i < count; ++i) {
const git_tree_entry *entry = git_tree_entry_byindex(tree, i);
rb_yield(rb_git_treeentry_fromC(entry));
}
return Qnil;
}
|