Class: Octokit::Gist
- Inherits:
-
Object
- Object
- Octokit::Gist
- Defined in:
- lib/octokit/gist.rb
Overview
Class to parse and create Gist URLs
Instance Attribute Summary collapse
-
#id ⇒ Object
!@attribute id @return [String] Gist ID.
Class Method Summary collapse
-
.from_url(url) ⇒ Object
Instantiate Gist object from Gist URL @ return [Gist].
Instance Method Summary collapse
-
#initialize(gist) ⇒ Gist
constructor
A new instance of Gist.
-
#to_s ⇒ String
Gist ID.
-
#url ⇒ String
Gist URL.
Constructor Details
#initialize(gist) ⇒ Gist
Returns a new instance of Gist
16 17 18 19 20 21 |
# File 'lib/octokit/gist.rb', line 16 def initialize(gist) case gist when Integer, String @id = gist.to_s end end |
Instance Attribute Details
#id ⇒ Object
!@attribute id @return [String] Gist ID
8 9 10 |
# File 'lib/octokit/gist.rb', line 8 def id @id end |
Class Method Details
.from_url(url) ⇒ Object
Instantiate Octokit::Gist object from Gist URL @ return [Gist]
12 13 14 |
# File 'lib/octokit/gist.rb', line 12 def self.from_url(url) Gist.new(URI.parse(url).path[1..-1]) end |
Instance Method Details
#to_s ⇒ String
Gist ID
25 26 27 |
# File 'lib/octokit/gist.rb', line 25 def to_s @id end |
#url ⇒ String
Gist URL
31 32 33 |
# File 'lib/octokit/gist.rb', line 31 def url "https://gist.github.com/#{@id}" end |