class RuneterraCards::Card
Represents a card.
@todo: add getters for set, faction, card number
Attributes
code[R]
The card code, for example “01DE123” @return [String]
Public Class Methods
new(code: nil, set: nil, faction_number: nil, card_number: nil)
click to toggle source
@param set [Fixnum] @param faction_number [Fixnum] @param card_number [Fixnum]
# File lib/runeterra_cards/card.rb, line 15 def initialize(code: nil, 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 end
Public Instance Methods
eql?(other)
click to toggle source
Returns true
if this and other both have the same card code.
@param other [Card] @return [Boolean]
# File lib/runeterra_cards/card.rb, line 32 def eql?(other) code.eql?(other.code) end
hash()
click to toggle source
Compute a hash code for this card. Two cards with the same card code will have the same hash code (and will compare using {#eql?}).
@see Object#hash. @return [Integer]
# File lib/runeterra_cards/card.rb, line 41 def hash code.hash end