Class: Instapaper::HTTP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, path, raw_format = false) ⇒ Response


8
9
10
11
12
# File 'lib/instapaper/http/response.rb', line 8

def initialize(response, path, raw_format = false)
  @response = response
  @path = path
  @raw_format = raw_format
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path


7
8
9
# File 'lib/instapaper/http/response.rb', line 7

def path
  @path
end

#raw_formatObject (readonly)

Returns the value of attribute raw_format


7
8
9
# File 'lib/instapaper/http/response.rb', line 7

def raw_format
  @raw_format
end

#responseObject (readonly)

Returns the value of attribute response


7
8
9
# File 'lib/instapaper/http/response.rb', line 7

def response
  @response
end

Instance Method Details

#bodyObject


14
15
16
# File 'lib/instapaper/http/response.rb', line 14

def body
  raw_format ? response.to_s : parsed
end

#error?Boolean


22
23
24
25
26
# File 'lib/instapaper/http/response.rb', line 22

def error?
  fail_if_body_unparseable unless raw_format
  fail_if_body_contains_error
  fail_if_http_error
end

#valid?Boolean


18
19
20
# File 'lib/instapaper/http/response.rb', line 18

def valid?
  !error?
end