Class: ZombieBattleground::Api::Responses::GetCardsResponse
- Inherits:
-
Object
- Object
- ZombieBattleground::Api::Responses::GetCardsResponse
- Includes:
- ActiveModel::Validations, ResponseHelper, ValidationHelper
- Defined in:
- lib/zombie_battleground/api/responses/get_cards_response.rb
Overview
Response validator for GetCards
Instance Attribute Summary collapse
-
#cards ⇒ Array<ZombieBattleground::Api::Models::Card>
readonly
the deck found for the page and limit.
-
#limit ⇒ Integer
readonly
the limit of results for the page.
-
#page ⇒ Integer
readonly
the page number of the results.
-
#remove_invalid ⇒ Boolean
flag to remove objects in response that are invalid during validation.
-
#total ⇒ Integer
readonly
the total number of results available.
Instance Method Summary collapse
-
#initialize(response) ⇒ ZombieBattleground::Api::GetCardsResponse
constructor
Creates a new GetCardsResponse.
Constructor Details
#initialize(response) ⇒ ZombieBattleground::Api::GetCardsResponse
Creates a new GetCardsResponse
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 97 def initialize(response) handle_errors(response) JSON.parse(response.body).each do |key, value| if key == 'cards' instance_variable_set( "@#{key}".to_sym, value.map { |card| ZombieBattleground::Api::Models::Card.new(card) } ) else instance_variable_set("@#{key}".to_sym, value) end end end |
Instance Attribute Details
#cards ⇒ Array<ZombieBattleground::Api::Models::Card> (readonly)
the deck found for the page and limit
66 67 68 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 66 def cards @cards end |
#limit ⇒ Integer (readonly)
the limit of results for the page
54 55 56 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 54 def limit @limit end |
#page ⇒ Integer (readonly)
the page number of the results
42 43 44 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 42 def page @page end |
#remove_invalid ⇒ Boolean
flag to remove objects in response that are invalid during validation
78 79 80 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 78 def remove_invalid @remove_invalid end |
#total ⇒ Integer (readonly)
the total number of results available
30 31 32 |
# File 'lib/zombie_battleground/api/responses/get_cards_response.rb', line 30 def total @total end |