class RuneterraCards::MetadataLoadError
This exception is raised if you try to parse data from Runeterra Data Dragon that is not in the expected form. The message will tell you what data was not right, and the {#card} attribute will tell you which card had issues, if possible.
@see CardMetadata#initialize CardMetadata#initialize for details on when this error is raised.
Attributes
Return the name or card code of the card that was missing an expected attribute. @return [String] name if the name was present @return [String] card code if the name was not present @return [nil] if neither name nor card code were present
Public Class Methods
Create a {MetadataLoadError MetadataLoadError} with a helpful message regarding an invalid value for rarityRef. @param [String] card The card name that had an invalid rarityRef value.
@param [String] given The value that rarityRef had. @param [Enumerable<String>] expected A list of values that would have been valid. @return [MetadataLoadError]
# File lib/runeterra_cards/errors.rb, line 97 def self.invalid_rarity(card, given, expected) new(card, "Invalid value for rarityRef, got: #{given}, expected one of: #{expected.join ', '}") end
@param [String] card The card's name or cardCode. @param [String] problem Details on the problem encountered loading the card.
# File lib/runeterra_cards/errors.rb, line 82 def initialize(card, problem) if card.nil? super("Error loading data for unknown card (no code or name): #{problem}") else super("Error loading data for card #{card}: #{problem}") end @card = card end