Class: ZombieBattleground::Api::Models::Deck

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

Overview

Validator for Deck

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deck) ⇒ ZombieBattleground::Api::Deck

Creates a new Deck

Examples:

deck = ZombieBattleground::Api::Deck.new(parsed_json)
# => ZombieBattleground::Api::Deck

Parameters:

  • card (Hash)

    Parsed JSON response



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/zombie_battleground/api/models/deck.rb', line 213

def initialize(deck)
  deck.each do |key, value|
    next if value.nil? # this is an illegal response, deck id 1 is bogus

    if key == 'cards'
      instance_variable_set(
        "@#{key}".to_sym, value.map { |card| ZombieBattleground::Api::Models::SimpleCard.new(card) }
      )
    elsif %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 Deck’s block_height

Examples:

deck.block_height #=> 939237

Returns:

  • (Integer)


172
173
174
# File 'lib/zombie_battleground/api/models/deck.rb', line 172

def block_height
  @block_height
end

#cardsArray<ZombieBattleground::Api::Models::SimpleCard> (readonly)

the Deck’s cards

Examples:

deck.cards #=> [ZombieBattleground::Api::Models::SimpleCard]

Returns:



112
113
114
# File 'lib/zombie_battleground/api/models/deck.rb', line 112

def cards
  @cards
end

#created_atTime (readonly)

the Deck’s created_at time

Examples:

deck.created_at #=> Time

Returns:

  • (Time)


40
41
42
# File 'lib/zombie_battleground/api/models/deck.rb', line 40

def created_at
  @created_at
end

#deck_idInteger (readonly)

the Deck’s deck_id

Examples:

deck.deck_id #=> 4

Returns:

  • (Integer)


76
77
78
# File 'lib/zombie_battleground/api/models/deck.rb', line 76

def deck_id
  @deck_id
end

#hero_idInteger (readonly)

the Deck’s hero_id

Examples:

deck.hero_id #=> 5

Returns:

  • (Integer)


100
101
102
# File 'lib/zombie_battleground/api/models/deck.rb', line 100

def hero_id
  @hero_id
end

#idInteger (readonly)

Deck’s id

Examples:

deck.id #=> 1812

Returns:

  • (Integer)


28
29
30
# File 'lib/zombie_battleground/api/models/deck.rb', line 28

def id
  @id
end

#is_deletedBoolean (readonly)

the Deck’s is_deleted

Examples:

deck.is_deleted #=> false

Returns:

  • (Boolean)


184
185
186
# File 'lib/zombie_battleground/api/models/deck.rb', line 184

def is_deleted
  @is_deleted
end

#nameString (readonly)

the Deck’s name

Examples:

deck.name #=> "Leaf Midrange"

Returns:

  • (String)


88
89
90
# File 'lib/zombie_battleground/api/models/deck.rb', line 88

def name
  @name
end

#primary_skill_idInteger (readonly)

the Deck’s primary_skill_id

Examples:

deck.primary_skill_id #=> 19

Returns:

  • (Integer)


124
125
126
# File 'lib/zombie_battleground/api/models/deck.rb', line 124

def primary_skill_id
  @primary_skill_id
end

#secondary_skill_idInteger (readonly)

the Deck’s secondary_skill_id

Examples:

deck.secondary_skill_id #=> 18

Returns:

  • (Integer)


136
137
138
# File 'lib/zombie_battleground/api/models/deck.rb', line 136

def secondary_skill_id
  @secondary_skill_id
end

#sender_addressString (readonly)

the Deck’s sender_address

Examples:

deck.sender_address #=> "0x62bb8C4452c3Fa7E9eEd6D9Ceaa4d3fe8E18E249"

Returns:

  • (String)


160
161
162
# File 'lib/zombie_battleground/api/models/deck.rb', line 160

def sender_address
  @sender_address
end

#updated_atTime (readonly)

the Deck’s updated_at time

Examples:

deck.updated_at #=> Time

Returns:

  • (Time)


52
53
54
# File 'lib/zombie_battleground/api/models/deck.rb', line 52

def updated_at
  @updated_at
end

#user_idString (readonly)

the Deck’s user_id

Examples:

deck.user_id #=> "ZombieSlayer_5773"

Returns:

  • (String)


64
65
66
# File 'lib/zombie_battleground/api/models/deck.rb', line 64

def user_id
  @user_id
end

#versionString (readonly)

the Deck’s version

Examples:

deck.version #=> "v5"

Returns:

  • (String)


148
149
150
# File 'lib/zombie_battleground/api/models/deck.rb', line 148

def version
  @version
end