Class: GitSniffer::Object
- Inherits:
-
Object
- Object
- GitSniffer::Object
- Defined in:
- lib/git_sniffer/object.rb
Instance Attribute Summary collapse
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(base, sha) ⇒ Object
constructor
A new instance of Object.
- #lazy_content_source ⇒ Object
- #lazy_type_source ⇒ Object
Methods included from Lazy
Methods included from Hook
Constructor Details
#initialize(base, sha) ⇒ Object
Returns a new instance of Object.
13 14 15 16 |
# File 'lib/git_sniffer/object.rb', line 13 def initialize(base, sha) @base = base @sha = sha end |
Instance Attribute Details
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
9 10 11 |
# File 'lib/git_sniffer/object.rb', line 9 def sha @sha end |
Class Method Details
.create_object(base, sha) ⇒ Object
35 36 37 |
# File 'lib/git_sniffer/object.rb', line 35 def create_object(base, sha) eval("GitSniffer::#{object_type(base, sha)}").new(base, sha) end |
.object_type(base, sha) ⇒ Object
39 40 41 |
# File 'lib/git_sniffer/object.rb', line 39 def object_type(base, sha) base.exec("cat-file -t #{sha}").chomp.capitalize end |
Instance Method Details
#eql?(other) ⇒ Boolean
30 31 32 |
# File 'lib/git_sniffer/object.rb', line 30 def eql?(other) self.class.equal?(other.class) && @sha == other.sha end |
#hash ⇒ Object
26 27 28 |
# File 'lib/git_sniffer/object.rb', line 26 def hash @sha.hash end |
#lazy_content_source ⇒ Object
22 23 24 |
# File 'lib/git_sniffer/object.rb', line 22 def lazy_content_source @base.exec("cat-file -p #{@sha}") end |
#lazy_type_source ⇒ Object
18 19 20 |
# File 'lib/git_sniffer/object.rb', line 18 def lazy_type_source @base.exec("cat-file -t #{@sha}").chomp end |