Class: Pathtraq::Request
- Inherits:
-
Object
- Object
- Pathtraq::Request
- Defined in:
- lib/pathtraq.rb
Instance Method Summary collapse
-
#initialize(url, params) ⇒ Request
constructor
A new instance of Request.
- #send ⇒ Object
Constructor Details
#initialize(url, params) ⇒ Request
Returns a new instance of Request.
124 125 126 127 128 |
# File 'lib/pathtraq.rb', line 124 def initialize(url, params) @uri = URI(url) @params = params.map {|key, val| "#{key}=#{val}" }.join("&") @uri.query = URI.escape(@params) if @params.size > 0 end |
Instance Method Details
#send ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pathtraq.rb', line 130 def send STDERR.puts "Pathtraq: request to #{@uri}" if $DEBUG begin res = @uri.read STDERR.puts "#{res.status.join(" ")} #{res.content_type}" if $DEBUG return res rescue OpenURI::HTTPError raise Error.new(res, @params) end end |