Class: Twitter::Request
- Inherits:
-
Object
- Object
- Twitter::Request
- Extended by:
- Forwardable
- Defined in:
- lib/twitter/request.rb
Constant Summary collapse
- API_VERSION =
'/1'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .delete(client, path, options = {}) ⇒ Object
- .get(client, path, options = {}) ⇒ Object
- .post(client, path, options = {}) ⇒ Object
- .put(client, path, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(client, method, path, options = {}) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(client, method, path, options = {}) ⇒ Request
Returns a new instance of Request.
26 27 28 |
# File 'lib/twitter/request.rb', line 26 def initialize(client, method, path, ={}) @client, @method, @path, @options = client, method, path, end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
22 23 24 |
# File 'lib/twitter/request.rb', line 22 def client @client end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
22 23 24 |
# File 'lib/twitter/request.rb', line 22 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/twitter/request.rb', line 22 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/twitter/request.rb', line 22 def path @path end |
Class Method Details
.delete(client, path, options = {}) ⇒ Object
18 19 20 |
# File 'lib/twitter/request.rb', line 18 def self.delete(client, path, ={}) new(client, :delete, path, ).perform end |
.get(client, path, options = {}) ⇒ Object
6 7 8 |
# File 'lib/twitter/request.rb', line 6 def self.get(client, path, ={}) new(client, :get, path, ).perform end |
.post(client, path, options = {}) ⇒ Object
10 11 12 |
# File 'lib/twitter/request.rb', line 10 def self.post(client, path, ={}) new(client, :post, path, ).perform end |
.put(client, path, options = {}) ⇒ Object
14 15 16 |
# File 'lib/twitter/request.rb', line 14 def self.put(client, path, ={}) new(client, :put, path, ).perform end |
Instance Method Details
#perform ⇒ Object
42 43 44 |
# File 'lib/twitter/request.rb', line 42 def perform Twitter.make_friendly(send("perform_#{method}")) end |
#uri ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/twitter/request.rb', line 30 def uri @uri ||= begin uri = URI.parse(API_VERSION + path) if [:query] && [:query] != {} uri.query = to_query([:query]) end uri.to_s end end |