Class: BreakingBad::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/breaking_bad/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/breaking_bad/client.rb', line 9

def initialize(uri)
  @uri = uri
  @response = nil
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/breaking_bad/client.rb', line 7

def response
  @response
end

#uriObject

Returns the value of attribute uri.



7
8
9
# File 'lib/breaking_bad/client.rb', line 7

def uri
  @uri
end

Instance Method Details

#get(path) ⇒ Object



14
15
16
17
18
# File 'lib/breaking_bad/client.rb', line 14

def get(path)
  uri = URI.join(@uri, path)
  response = Net::HTTP.get_response(uri)
  @response = JSON.parse(response.body, symbolize_names: true)
end