Exception: RuneterraCards::MetadataLoadError
- Inherits:
-
StandardError
- Object
- StandardError
- RuneterraCards::MetadataLoadError
- Defined in:
- lib/runeterra_cards/errors.rb
Overview
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.
Instance Attribute Summary collapse
-
#card ⇒ String?
readonly
Return the name or card code of the card that was missing an expected attribute.
Class Method Summary collapse
-
.invalid_rarity(card, given, expected) ⇒ MetadataLoadError
Create a MetadataLoadError with a helpful message regarding an invalid value for rarityRef.
Instance Method Summary collapse
-
#initialize(card, problem) ⇒ MetadataLoadError
constructor
A new instance of MetadataLoadError.
Constructor Details
#initialize(card, problem) ⇒ MetadataLoadError
Returns a new instance of MetadataLoadError.
82 83 84 85 86 87 88 89 |
# 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 |
Instance Attribute Details
#card ⇒ String? (readonly)
Return the name or card code of the card that was missing an expected attribute.
78 79 80 |
# File 'lib/runeterra_cards/errors.rb', line 78 def card @card end |
Class Method Details
.invalid_rarity(card, given, expected) ⇒ MetadataLoadError
Create a MetadataLoadError with a helpful message regarding an invalid value for rarityRef.
97 98 99 |
# 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 |