Class: PixabayApi::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



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

def initialize(response)
  self.response = response
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#status_codeObject

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/pixabay_api/response.rb', line 15

def failed?
  response.code.to_i != 200
end

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pixabay_api/response.rb', line 11

def success?
  response.code == 200
end