Class: RuneterraCards::CardAndCount Deprecated
- Inherits:
-
Object
- Object
- RuneterraCards::CardAndCount
- 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
-
#code ⇒ String
readonly
The card code, for example “01DE123”.
-
#count ⇒ Fixnum
readonly
How many of this card are in a collection (between 1-3).
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(code: nil, count:, set: nil, faction_number: nil, card_number: nil) ⇒ CardAndCount
constructor
A new instance of CardAndCount.
Constructor Details
#initialize(code: nil, count:, set: nil, faction_number: nil, card_number: nil) ⇒ CardAndCount
Returns a new instance of CardAndCount.
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
#code ⇒ String (readonly)
The card code, for example “01DE123”
9 10 11 |
# File 'lib/runeterra_cards/card_and_count.rb', line 9 def code @code end |
#count ⇒ Fixnum (readonly)
How many of this card are in a collection (between 1-3).
13 14 15 |
# File 'lib/runeterra_cards/card_and_count.rb', line 13 def count @count end |
Instance Method Details
#eql?(other) ⇒ 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 |
#hash ⇒ Object
37 38 39 |
# File 'lib/runeterra_cards/card_and_count.rb', line 37 def hash [code, count].hash end |