Class: ZombieBattleground::Api::Responses::GetMatchesResponse
- Inherits:
-
Object
- Object
- ZombieBattleground::Api::Responses::GetMatchesResponse
- Includes:
- ActiveModel::Validations, ResponseHelper, ValidationHelper
- Defined in:
- lib/zombie_battleground/api/responses/get_matches_response.rb
Overview
Response validator for GetMatches
Instance Attribute Summary collapse
-
#limit ⇒ Integer
readonly
the limit of results for the page.
-
#matches ⇒ Array<ZombieBattleground::Api::Models::Match>
readonly
the matches found for the page and limit.
-
#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::GetMatchesResponse
constructor
Creates a new GetMatchesResponse.
Constructor Details
#initialize(response) ⇒ ZombieBattleground::Api::GetMatchesResponse
Creates a new GetMatchesResponse
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/zombie_battleground/api/responses/get_matches_response.rb', line 97 def initialize(response) handle_errors(response) JSON.parse(response.body).each do |key, value| if key == 'matches' instance_variable_set( "@#{key}".to_sym, value.map { |match| ZombieBattleground::Api::Models::Match.new(match) } ) else instance_variable_set("@#{key}".to_sym, value) end end end |
Instance Attribute Details
#limit ⇒ Integer (readonly)
the limit of results for the page
54 55 56 |
# File 'lib/zombie_battleground/api/responses/get_matches_response.rb', line 54 def limit @limit end |
#matches ⇒ Array<ZombieBattleground::Api::Models::Match> (readonly)
the matches found for the page and limit
66 67 68 |
# File 'lib/zombie_battleground/api/responses/get_matches_response.rb', line 66 def matches @matches end |
#page ⇒ Integer (readonly)
the page number of the results
42 43 44 |
# File 'lib/zombie_battleground/api/responses/get_matches_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_matches_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_matches_response.rb', line 30 def total @total end |