Skip to content

Commit

Permalink
Added two shortcut methods, for picking trees/blobs only
Browse files Browse the repository at this point in the history
  • Loading branch information
Voker57 committed Feb 17, 2009
1 parent a6015ed commit dbfeb5c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/grit/tree.rb
Expand Up @@ -94,11 +94,26 @@ def /(file)
self.contents.find { |c| c.name == file }
end
end

# Pretty object inspection
def inspect
%Q{#<Grit::Tree "#{@id}">}
end

# Find only Tree objects from contents
def trees
contents.select {|v| v.kind_of? Tree}
end

# Find only Blob objects from contents
def blobs
contents.select {|v| v.kind_of? Blob}
end

# Compares trees by name
def <=>(other)
name <=> other.name
end
end # Tree

end # Grit

0 comments on commit dbfeb5c

Please sign in to comment.