Class: BlockstreamSatellite::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
# File 'lib/blockstream_satellite/response.rb', line 6

def initialize(response)
  if response.is_a?(Faraday::ClientError)
    @error = response
  else
    @response = response
    @body = response.body
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#[](key) ⇒ Object



19
20
21
# File 'lib/blockstream_satellite/response.rb', line 19

def [](key)
  self.body[key.to_s]
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  self.error.nil? && !self.response.nil? && self.response.success?
end