Class: Twitter::Request

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/twitter/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, method, path, options = {}) ⇒ Request

Returns a new instance of Request.



17
18
19
# File 'lib/twitter/request.rb', line 17

def initialize(client, method, path, options={})
  @client, @method, @path, @options = client, method, path, {:mash => true}.merge(options)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



13
14
15
# File 'lib/twitter/request.rb', line 13

def client
  @client
end

#methodObject (readonly)

Returns the value of attribute method.



13
14
15
# File 'lib/twitter/request.rb', line 13

def method
  @method
end

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/twitter/request.rb', line 13

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/twitter/request.rb', line 13

def path
  @path
end

Class Method Details

.get(client, path, options = {}) ⇒ Object



5
6
7
# File 'lib/twitter/request.rb', line 5

def self.get(client, path, options={})
  new(client, :get, path, options).perform
end

.post(client, path, options = {}) ⇒ Object



9
10
11
# File 'lib/twitter/request.rb', line 9

def self.post(client, path, options={})
  new(client, :post, path, options).perform
end

Instance Method Details

#performObject



33
34
35
# File 'lib/twitter/request.rb', line 33

def perform
  make_friendly(send("perform_#{method}"))
end

#uriObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/twitter/request.rb', line 21

def uri
  @uri ||= begin
    uri = URI.parse(path)
    
    if options[:query] && options[:query] != {}
      uri.query = to_query(options[:query])
    end
    
    uri.to_s
  end
end