Class: Gista::GistRequest

Inherits:
ApiRequest show all
Defined in:
lib/gista/gist_request.rb

Overview

Special Github API request to create a new gist. It requires an OAuth token for authorization, and options for what file to post.

See the API docs for what options are expected to create a new Gist.

Examples:

Creating a Gist

GistRequest.new('acc829df', {
  public: false,
  files: {
    file1: { content: 'my content' }
  }
}).fetch('html_url')
# => "http://gist.github.com/fbed697547047a733434"

See Also:

Constant Summary

Constants inherited from ApiRequest

ApiRequest::CONTENT_TYPE, ApiRequest::OPEN_TIMEOUT, ApiRequest::PORT, ApiRequest::READ_TIMEOUT, ApiRequest::URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApiRequest

#fetch

Constructor Details

#initialize(token, options = {}) ⇒ GistRequest

Returns a new instance of GistRequest.



29
30
31
# File 'lib/gista/gist_request.rb', line 29

def initialize(token, options = {})
  @token, @options = token, options
end

Instance Attribute Details

#optionsHash (readonly)

Options containing information about files, filenames and visibility

Returns:

  • (Hash)


27
28
29
# File 'lib/gista/gist_request.rb', line 27

def options
  @options
end

#tokenString (readonly)

Authorization token to authorize with Github.



23
24
25
# File 'lib/gista/gist_request.rb', line 23

def token
  @token
end