Class: RuneterraCards::CardAndCount Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/runeterra_cards/card_and_count.rb

Overview

Deprecated.

Represents a card and how many of that card are in a collection.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: nil, count:, set: nil, faction_number: nil, card_number: nil) ⇒ CardAndCount

Returns a new instance of CardAndCount.

Parameters:

  • set (Fixnum) (defaults to: nil)
  • faction_number (Fixnum) (defaults to: nil)
  • card_number (Fixnum) (defaults to: nil)
  • count (Fixnum)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/runeterra_cards/card_and_count.rb', line 19

def initialize(code: nil, count:, set: nil, faction_number: nil, card_number: nil)
  if code
    raise if set || faction_number || card_number

    @code = code
  else
    padded_set = format('%<i>02d', i: set)
    faction = FACTION_IDENTIFIERS_FROM_INT.fetch(faction_number) { |key| raise UnrecognizedFactionError, key }
    padded_card_number = format('%<i>03d', i: card_number)
    @code = "#{padded_set}#{faction}#{padded_card_number}"
  end
  @count = count
end

Instance Attribute Details

#codeString (readonly)

The card code, for example “01DE123”

Returns:

  • (String)


9
10
11
# File 'lib/runeterra_cards/card_and_count.rb', line 9

def code
  @code
end

#countFixnum (readonly)

How many of this card are in a collection (between 1-3).

Returns:

  • (Fixnum)


13
14
15
# File 'lib/runeterra_cards/card_and_count.rb', line 13

def count
  @count
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/runeterra_cards/card_and_count.rb', line 33

def eql?(other)
  code.eql?(other.code) && count.equal?(other.count)
end

#hashObject



37
38
39
# File 'lib/runeterra_cards/card_and_count.rb', line 37

def hash
  [code, count].hash
end