Sha256: 422928e47f0a6e6aa09a08a47e91f294e09e78be92ea8746476334896456b2ec

Contents?: true

Size: 929 Bytes

Versions: 49

Compression:

Stored size: 929 Bytes

Contents

module Rugged
  class Tree
    include Enumerable

    attr_reader :owner
    alias repo owner

    def diff(other = nil, options = nil)
      Tree.diff(repo, self, other, options)
    end

    def inspect
      data = "#<Rugged::Tree:#{object_id} {oid: #{oid}}>\n"
      self.each { |e| data << "  <\"#{e[:name]}\" #{e[:oid]}>\n" }
      data
    end

    # Walks the tree but only yields blobs
    def walk_blobs(mode=:postorder)
      self.walk(mode) { |root, e| yield root, e if e[:type] == :blob }
    end

    # Walks the tree but only yields subtrees
    def walk_trees(mode=:postorder)
      self.walk(mode) { |root, e| yield root, e if e[:type] == :tree }
    end

    # Iterate over the blobs in this tree
    def each_blob
      self.each { |e| yield e if e[:type] == :blob }
    end

    # Iterat over the subtrees in this tree
    def each_tree
      self.each { |e| yield e if e[:type] == :tree }
    end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
rugged-0.24.6.1 lib/rugged/tree.rb
rugged-0.24.5 lib/rugged/tree.rb
rugged-0.25.0b10 lib/rugged/tree.rb
rugged-0.25.0b9 lib/rugged/tree.rb
rugged-0.25.0b8 lib/rugged/tree.rb
rugged-0.25.0b7 lib/rugged/tree.rb
rugged-0.25.0b6 lib/rugged/tree.rb
rugged-0.25.0b5 lib/rugged/tree.rb
rugged-0.25.0b4 lib/rugged/tree.rb
rugged-0.25.0b3 lib/rugged/tree.rb
rugged-0.25.0b2 lib/rugged/tree.rb
rugged-0.25.0b1 lib/rugged/tree.rb
rugged-0.24.0 lib/rugged/tree.rb
rugged-0.24.0b14 lib/rugged/tree.rb
rugged-0.24.0b13 lib/rugged/tree.rb
rdavila-rugged-0.24.0b13 lib/rugged/tree.rb
rugged-0.24.0b12 lib/rugged/tree.rb
rugged-0.24.0b11 lib/rugged/tree.rb
rugged-0.24.0b9 lib/rugged/tree.rb
rugged-0.24.0b8 lib/rugged/tree.rb