123456789_123456789_123456789_123456789_123456789_

Class: Octokit::Gist

Relationships & Source Files
Inherits: Object
Defined in: lib/octokit/gist.rb

Overview

Class to parse and create Gist URLs

Class Method Summary

Instance Attribute Summary

  • #id rw

    !@attribute id.

Instance Method Summary

Constructor Details

.new(gist) ⇒ Gist

[ GitHub ]

  
# File 'lib/octokit/gist.rb', line 16

def initialize(gist)
  case gist
  when Integer, String
    @id = gist.to_s
  end
end

Class Method Details

.from_url(url)

Instantiate Gist object from Gist URL @ return [Gist]

[ GitHub ]

  
# File 'lib/octokit/gist.rb', line 12

def self.from_url(url)
  Gist.new(URI.parse(url).path[1..-1])
end

Instance Attribute Details

#id (rw)

!@attribute id @return [String] Gist ID

[ GitHub ]

  
# File 'lib/octokit/gist.rb', line 8

attr_accessor :id

Instance Method Details

#to_sString

Gist ID

[ GitHub ]

  
# File 'lib/octokit/gist.rb', line 25

def to_s
  @id
end

#urlString

Gist URL

[ GitHub ]

  
# File 'lib/octokit/gist.rb', line 31

def url
  "https://gist.github.com/#{@id}"
end