class ZombieBattleground::Api::Models::Match

Validator for Match

Attributes

block_height[R]

@!attribute [r] block_height the Match's block_height

@return [Integer]

@example

match.block_height #=> 497513

@api public

created_at[R]

@!attribute [r] created_at the Match's created_at time

@return [Time]

@example

match.created_at #=> Time

@api public

id[R]

@!attribute [r] id the Match's id

@return [Integer]

@example

match.id #=> 1

@api public

player1_accepted[R]

@!attribute [r] player1_accepted the Match's player1_accepted

@return [Boolean]

@example

match.player1_accepted #=> true

@api public

player1_deck_id[R]

@!attribute [r] player1_deck_id the Match's player1_deck_id

@return [Integer]

@example

match.player1_deck_id #=> 1

@api public

player1_id[R]

@!attribute [r] player1_id the Match's player1_id

@return [String]

@example

match.player1_id #=> "ZombieSlayer_16601"

@api public

player2_accepted[R]

@!attribute [r] player2_accepted the Match's player2_accepted

@return [Boolean]

@example

match.player2_accepted #=> true

@api public

player2_deck_id[R]

@!attribute [r] player2_deck_id the Match's player2_deck_id

@return [Integer]

@example

match.player2_deck_id #=> 4

@api public

player2_id[R]

@!attribute [r] player2_id the Match's player2_id

@return [String]

@example

match.player2_id #=> "ZombieSlayer_50758"

@api public

random_seed[R]

@!attribute [r] random_seed the Match's random_seed

@return [Integer]

@example

match.random_seed #=> 1548242486

@api public

status[R]

@!attribute [r] status the Match's status

@return [String]

@example

match.status #=> "Ended"

@api public

updated_at[R]

@!attribute [r] updated_at the Match's updated_at time

@return [Time]

@example

match.updated_at #=> Time

@api public

version[R]

@!attribute [r] version the Match's version

@return [String]

@example

match.version #=> "v3"

@api public

winner_id[R]

@!attribute [r] winner_id the Match's winner_id

@return [String]

@example

match.winner_id #=> "ZombieSlayer_507586"

@api public

Public Class Methods

new(match) click to toggle source

Creates a new Match

@param match [Hash] Parsed JSON response

@return [ZombieBattleground::Api::Match]

@example

match = ZombieBattleground::Api::Match.new(parsed_json)
# => ZombieBattleground::Api::Match

@api public

# File lib/zombie_battleground/api/models/match.rb, line 211
def initialize(match)
  match.each do |key, value|
    next if value.nil? # this is an illegal response, match id 1 is bogus

    if %w[created_at updated_at].include?(key)
      instance_variable_set("@#{key}".to_sym, Time.parse(value))
    else
      instance_variable_set("@#{key}".to_sym, value)
    end
  end
end