Class: Octokit::Gist

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

Overview

Class to parse and create Gist URLs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject

!@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_sString

Gist ID

Returns:

  • (String)


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

def to_s
  @id
end

#urlString

Gist URL

Returns:

  • (String)


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

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