Class: Flute::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/flute/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



4
5
6
7
# File 'lib/flute/response.rb', line 4

def initialize(response)
  @status = response.code
  @body = response.body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/flute/response.rb', line 3

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/flute/response.rb', line 3

def status
  @status
end

Instance Method Details

#parse_htmlObject



13
14
15
# File 'lib/flute/response.rb', line 13

def parse_html
  @parse_html ||= Document.parse(@body)
end

#parse_jsonObject



17
18
19
# File 'lib/flute/response.rb', line 17

def parse_json
  @parse_json ||= JSON.parse(@body).symbolize_keys
end

#success?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/flute/response.rb', line 9

def success?
  200 <= @status && @status < 300
end