class RuneterraCards::CardMetadata

Represents metadata for a single card. Metadata is all meaning the game imbues upon a card code, including things like cost, health, etc and also localised information such as name and description.

Currently this class only represents a thin sliver of metadata as required by its downstream consumers.

@see CardAndCount

Constants

RARITIES

Attributes

card_code[R]

Returns the card_code attribute. For example: “01NX055”. @return [String]

cost[R]

Returns the cost attribute. For example: 3. @return [Fixnum]

name[R]

Returns the name attribute. The name is the localised name that the card would have in game. For example: “House Spider”. @return [String]

rarity[R]

Returns the card's rarity as a symbol. Can be one of: :none, :common, :rare, :epic, or :champion @return [Symbol]

Public Class Methods

new(hash) click to toggle source

Creates a single {CardMetadata} Object from the supplied Hash of data. This is intended for use with the data files from Legends of Runeterra Data Dragon, and it expects a Hash representing a single card from the parsed JSON data files from Data Dragon.

@param hash [Hash] Card data from Legends of Runeterra Data Dragon @option hash [String] name @option hash [String] cardCode @option hash [Boolean] collectible @option hash [Fixnum] cost @option hash [String] rarityRef

@raise [MissingCardDataError] if any of the expected hash parameters are missing, or if rarityRef contains an

unexpected value.
# File lib/runeterra_cards/card_metadata.rb, line 50
def initialize(hash)
  begin
    @name, @card_code, @collectible, @cost, rarity_ref =
      hash.fetch_values('name', 'cardCode', 'collectible', 'cost', 'rarityRef')
  rescue KeyError => e
    raise MetadataLoadError.new(hash['name'] || hash['cardCode'], "Missing expected key: #{e.key}")
  end

  @rarity = RARITIES[rarity_ref]
  return unless rarity.nil?

  raise MetadataLoadError.invalid_rarity(name, rarity_ref, RARITIES.keys)
end

Public Instance Methods

collectible?() click to toggle source

Whether or not the card is collectible.

# File lib/runeterra_cards/card_metadata.rb, line 65
def collectible?
  @collectible
end