Class: NPR::API::Response

Inherits:
Object
  • Object
show all
Includes:
Concern::Relation
Defined in:
lib/npr/api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concern::Relation

included

Constructor Details

#initialize(response) ⇒ Response




17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/npr/api/response.rb', line 17

def initialize(response)
  create_relations(response)

  @_response = response
  @raw       = response.body
  @version = @raw["version"]

  if list = @raw["list"]
    @list = NPR::Entity::List.new(list)
  end

  Array.wrap(@raw["message"]).each do |message|
    @messages.push NPR::API::Message.new(message)
  end
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



13
14
15
# File 'lib/npr/api/response.rb', line 13

def list
  @list
end

#messagesObject (readonly)

Returns the value of attribute messages.



13
14
15
# File 'lib/npr/api/response.rb', line 13

def messages
  @messages
end

#rawObject (readonly)

Returns the value of attribute raw.



13
14
15
# File 'lib/npr/api/response.rb', line 13

def raw
  @raw
end

#versionObject (readonly)

Returns the value of attribute version.



13
14
15
# File 'lib/npr/api/response.rb', line 13

def version
  @version
end