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

TODO: Change this to a keyword argument (needs a major version bump)



10
11
12
13
14
# File 'lib/instapaper/http/response.rb', line 10

def initialize(response, path, raw_format = false) # rubocop:disable Style/OptionalBooleanParameter
  @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



16
17
18
# File 'lib/instapaper/http/response.rb', line 16

def body
  raw_format ? response.to_s : parsed
end

#error?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/instapaper/http/response.rb', line 24

def error?
  fail_if_body_unparseable unless raw_format
  fail_if_body_contains_error
  fail_if_http_error
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/instapaper/http/response.rb', line 20

def valid?
  !error?
end