Class: GitMeta::Get

Inherits:
Object
  • Object
show all
Defined in:
lib/git_meta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sha, key = nil) ⇒ Get

Returns a new instance of Get.



37
38
39
40
41
42
43
# File 'lib/git_meta.rb', line 37

def initialize(sha, key=nil)
  output = IO.popen("git-cat-file -p #{sha}", 'r') do |git_cat_file|
    git_cat_file.read
  end
  self.scanner = Scanner.new(output)
  self.key = key
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



36
37
38
# File 'lib/git_meta.rb', line 36

def key
  @key
end

#scannerObject

Returns the value of attribute scanner.



36
37
38
# File 'lib/git_meta.rb', line 36

def scanner
  @scanner
end

Instance Method Details

#to_sObject



45
46
47
# File 'lib/git_meta.rb', line 45

def to_s
  key ? @scanner.info[key] : @scanner.info.to_s
end