class MtgRb::Expansion
This is a set of magic cards that was released together. They’re unique by name. They also have a three-character shortcode.
Attributes
block[R]
border[R]
code[R]
name[R]
online_only[R]
printings[R]
release_date[R]
type[R]
Public Class Methods
from_hash(expansion_hash)
click to toggle source
@param [Hash] An entry in AllSets.json
# File lib/mtg_rb/expansion.rb, line 8 def self.from_hash(expansion_hash) release_date = if expansion_hash.key?("releaseDate") Date.strptime(expansion_hash.fetch("releaseDate"), "%Y-%m-%d") else nil end self.new({ name: expansion_hash.fetch("name"), code: expansion_hash.fetch("code"), release_date: release_date, border: expansion_hash.fetch("border"), block: expansion_hash.fetch("block", nil), type: expansion_hash.fetch("type", nil), online_only: expansion_hash.fetch("onlineOnly", false), printings: [], # will be added later }) rescue KeyError => err p err p expansion_hash end
new(name:, code:, release_date:, border:, block:, type:, online_only:, printings:)
click to toggle source
# File lib/mtg_rb/expansion.rb, line 33 def initialize(name:, code:, release_date:, border:, block:, type:, online_only:, printings:) @name = name @code = code @release_date = release_date @border = border @block = block @type = type @online_only = online_only @printings = printings end