diff --git a/lib/grit/tree.rb b/lib/grit/tree.rb index 832ba28a..2fe70836 100644 --- a/lib/grit/tree.rb +++ b/lib/grit/tree.rb @@ -94,11 +94,26 @@ def /(file) self.contents.find { |c| c.name == file } end end - + # Pretty object inspection def inspect %Q{#} 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