Class: GithubApi::Tree
- Inherits:
-
Object
- Object
- GithubApi::Tree
- Defined in:
- lib/github-api/other.rb
Overview
Tree class
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
- #file(path) ⇒ Object
-
#initialize(repo, data) ⇒ Tree
constructor
A new instance of Tree.
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
#data ⇒ Object
Returns the value of attribute data.
57 58 59 |
# File 'lib/github-api/other.rb', line 57 def data @data end |
#repo ⇒ Object
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 |