Class: ZombieBattleground::Api::Models::Match

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, ValidationHelper
Defined in:
lib/zombie_battleground/api/models/match.rb

Overview

Validator for Match

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match) ⇒ ZombieBattleground::Api::Match

Creates a new Match

Examples:

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

Parameters:

  • match (Hash)

    Parsed JSON response



211
212
213
214
215
216
217
218
219
220
221
# 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

Instance Attribute Details

#block_heightInteger (readonly)

the Match’s block_height

Examples:

match.block_height #=> 497513

Returns:

  • (Integer)


182
183
184
# File 'lib/zombie_battleground/api/models/match.rb', line 182

def block_height
  @block_height
end

#created_atTime (readonly)

the Match’s created_at time

Examples:

match.created_at #=> Time

Returns:

  • (Time)


38
39
40
# File 'lib/zombie_battleground/api/models/match.rb', line 38

def created_at
  @created_at
end

#idInteger (readonly)

the Match’s id

Examples:

match.id #=> 1

Returns:

  • (Integer)


26
27
28
# File 'lib/zombie_battleground/api/models/match.rb', line 26

def id
  @id
end

#player1_acceptedBoolean (readonly)

the Match’s player1_accepted

Examples:

match.player1_accepted #=> true

Returns:

  • (Boolean)


86
87
88
# File 'lib/zombie_battleground/api/models/match.rb', line 86

def player1_accepted
  @player1_accepted
end

#player1_deck_idInteger (readonly)

the Match’s player1_deck_id

Examples:

match.player1_deck_id #=> 1

Returns:

  • (Integer)


110
111
112
# File 'lib/zombie_battleground/api/models/match.rb', line 110

def player1_deck_id
  @player1_deck_id
end

#player1_idString (readonly)

the Match’s player1_id

Examples:

match.player1_id #=> "ZombieSlayer_16601"

Returns:

  • (String)


62
63
64
# File 'lib/zombie_battleground/api/models/match.rb', line 62

def player1_id
  @player1_id
end

#player2_acceptedBoolean (readonly)

the Match’s player2_accepted

Examples:

match.player2_accepted #=> true

Returns:

  • (Boolean)


98
99
100
# File 'lib/zombie_battleground/api/models/match.rb', line 98

def player2_accepted
  @player2_accepted
end

#player2_deck_idInteger (readonly)

the Match’s player2_deck_id

Examples:

match.player2_deck_id #=> 4

Returns:

  • (Integer)


122
123
124
# File 'lib/zombie_battleground/api/models/match.rb', line 122

def player2_deck_id
  @player2_deck_id
end

#player2_idString (readonly)

the Match’s player2_id

Examples:

match.player2_id #=> "ZombieSlayer_50758"

Returns:

  • (String)


74
75
76
# File 'lib/zombie_battleground/api/models/match.rb', line 74

def player2_id
  @player2_id
end

#random_seedInteger (readonly)

the Match’s random_seed

Examples:

match.random_seed #=> 1548242486

Returns:

  • (Integer)


158
159
160
# File 'lib/zombie_battleground/api/models/match.rb', line 158

def random_seed
  @random_seed
end

#statusString (readonly)

the Match’s status

Examples:

match.status #=> "Ended"

Returns:

  • (String)


134
135
136
# File 'lib/zombie_battleground/api/models/match.rb', line 134

def status
  @status
end

#updated_atTime (readonly)

the Match’s updated_at time

Examples:

match.updated_at #=> Time

Returns:

  • (Time)


50
51
52
# File 'lib/zombie_battleground/api/models/match.rb', line 50

def updated_at
  @updated_at
end

#versionString (readonly)

the Match’s version

Examples:

match.version #=> "v3"

Returns:

  • (String)


146
147
148
# File 'lib/zombie_battleground/api/models/match.rb', line 146

def version
  @version
end

#winner_idString (readonly)

the Match’s winner_id

Examples:

match.winner_id #=> "ZombieSlayer_507586"

Returns:

  • (String)


170
171
172
# File 'lib/zombie_battleground/api/models/match.rb', line 170

def winner_id
  @winner_id
end