class Marvel::Api::Response
Attributes
body[R]
count[R]
etag[R]
headers[R]
limit[R]
offset[R]
results[R]
status[R]
total[R]
Public Class Methods
new(status:, headers:, body:)
click to toggle source
# File lib/marvel/api/response.rb, line 7 def initialize(status:, headers:, body:) @status = status @headers = headers @body = body parse_body end
Private Instance Methods
parse_body()
click to toggle source
# File lib/marvel/api/response.rb, line 17 def parse_body data = JSON.parse(body) @etag = data['etag'] methods = %w[offset limit total count results] methods.each do |method_name| value = data['data'][method_name] instance_variable_set(:"@#{method_name}", value) end rescue nil end