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

- (Gist) initialize(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 Fixnum, String
    @id = gist.to_s
  end
end

Instance Attribute Details

- (Object) id

!@attribute id

@return [String] Gist ID


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

def id
  @id
end

Class Method Details

+ (Object) from_url(url)

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

- (String) to_s

Gist ID

Returns:

  • (String)


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

def to_s
  @id
end

- (String) url

Gist URL

Returns:

  • (String)


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

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