Class: PcURL::Request
- Inherits:
-
Object
- Object
- PcURL::Request
- Defined in:
- lib/pcurl/request.rb
Instance Method Summary collapse
- #get(url) ⇒ Object
- #parse_response(response) ⇒ Object
- #prettify(response) ⇒ Object
- #request(url) ⇒ Object
Instance Method Details
#get(url) ⇒ Object
13 14 15 |
# File 'lib/pcurl/request.rb', line 13 def get(url) Curl.get(url).body_str end |
#parse_response(response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/pcurl/request.rb', line 17 def parse_response(response) begin JSON.parse response rescue raise "JSON parsing exception for response: #{response}" end end |
#prettify(response) ⇒ Object
25 26 27 |
# File 'lib/pcurl/request.rb', line 25 def prettify(response) JSON.pretty_generate response end |
#request(url) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/pcurl/request.rb', line 5 def request(url) response = get url parsed_response = parse_response response pretty_response = prettify(parsed_response) puts pretty_response pretty_response end |