Module: Marvel::Response

Included in:
Request
Defined in:
lib/marvel/error.rb,
lib/marvel/response.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



18
19
20
# File 'lib/marvel/response.rb', line 18

def code
  @code
end

#countObject (readonly)

Returns the value of attribute count.



18
19
20
# File 'lib/marvel/response.rb', line 18

def count
  @count
end

#etagObject (readonly)

Returns the value of attribute etag.



18
19
20
# File 'lib/marvel/response.rb', line 18

def etag
  @etag
end

#limitObject (readonly)

Returns the value of attribute limit.



18
19
20
# File 'lib/marvel/response.rb', line 18

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



18
19
20
# File 'lib/marvel/response.rb', line 18

def offset
  @offset
end

#statusObject (readonly)

Returns the value of attribute status.



18
19
20
# File 'lib/marvel/response.rb', line 18

def status
  @status
end

#totalObject (readonly)

Returns the value of attribute total.



18
19
20
# File 'lib/marvel/response.rb', line 18

def total
  @total
end

Class Method Details

.create(response_hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/marvel/response.rb', line 3

def self.create(response_hash)
  results = response_hash.data.results.dup rescue response_hash
  results.extend(self)
  results.instance_exec do
    @code   = response_hash.code
    @status = response_hash.status
    @etag   = response_hash.etag
    @offset = response_hash.data.offset
    @limit  = response_hash.data.limit
    @total  = response_hash.data.total
    @count  = response_hash.data.count
  end
  results
end