Class: GithubApi::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/github-api/other.rb

Overview

Tree class


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, data) ⇒ Tree

Returns a new instance of Tree.



59
60
61
62
# File 'lib/github-api/other.rb', line 59

def initialize(repo, data)
  @repo = repo
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



57
58
59
# File 'lib/github-api/other.rb', line 57

def data
  @data
end

#repoObject

Returns the value of attribute repo.



57
58
59
# File 'lib/github-api/other.rb', line 57

def repo
  @repo
end

Instance Method Details

#file(path) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/github-api/other.rb', line 64

def file(path)
  blob_ref = data["tree"].find { |b| b["path"] == path}
  unless blob_ref.nil?
    sha = blob_ref["sha"]
    @repo.blob(sha)
  else
    # throw error because the blob is not there
  end
end