Class: BerlinBuehnen::Response

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

Direct Known Subclasses

ListResponse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_response) ⇒ Response

Returns a new instance of Response.



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

def initialize(json_response)
  @json_response = json_response
end

Instance Attribute Details

#json_responseObject (readonly)

Returns the value of attribute json_response.



3
4
5
# File 'lib/berlin_buehnen/response.rb', line 3

def json_response
  @json_response
end

Class Method Details

.create(response) ⇒ Object



5
6
7
8
9
# File 'lib/berlin_buehnen/response.rb', line 5

def self.create(response)
  json_response = JSON.parse(response.body)

  json_response.has_key?("meta") ? ListResponse.new(json_response) : new(json_response)
end

Instance Method Details

#dataObject



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

def data
  @data ||= @json_response
end