Class: MtgRb::Printing

Inherits:
Object
  • Object
show all
Defined in:
lib/mtg_rb/printing.rb

Overview

This joins some ideas together in “concrete” piece of paper.

  • Card

  • Expansion

  • Artist

Some attributes come in “Cards” from MTGJSON but really belong to the printing.

  • Number

  • Flavor text

  • Artist

  • Rarity

  • ?? others?

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card:, expansion:, artist:, flavor:, rarity:, number:, multiverseid:) ⇒ Printing

Returns a new instance of Printing.



31
32
33
34
35
36
37
38
39
# File 'lib/mtg_rb/printing.rb', line 31

def initialize(card:, expansion:, artist:, flavor:, rarity:, number:, multiverseid:)
  @card = card
  @expansion = expansion
  @artist = artist
  @flavor = flavor
  @rarity = rarity
  @number = number
  @multiverseid = multiverseid
end

Instance Attribute Details

#artistObject (readonly)

Returns the value of attribute artist.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def artist
  @artist
end

#cardObject (readonly)

Returns the value of attribute card.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def card
  @card
end

#expansionObject (readonly)

Returns the value of attribute expansion.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def expansion
  @expansion
end

#flavorObject (readonly)

Returns the value of attribute flavor.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def flavor
  @flavor
end

#multiverseidObject (readonly)

Returns the value of attribute multiverseid.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def multiverseid
  @multiverseid
end

#numberObject (readonly)

Returns the value of attribute number.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def number
  @number
end

#rarityObject (readonly)

Returns the value of attribute rarity.



29
30
31
# File 'lib/mtg_rb/printing.rb', line 29

def rarity
  @rarity
end

Class Method Details

.from_card_hash(expansion:, card:, artist:, card_hash:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mtg_rb/printing.rb', line 14

def self.from_card_hash(expansion:, card:, artist:, card_hash:)
  self.new(
    card: card,
    expansion: expansion,
    artist: artist,
    flavor: card_hash.fetch("flavor", ""),
    rarity: card_hash.fetch("rarity"),
    number: card_hash.fetch("number", nil),
    multiverseid: card_hash.fetch("multiverseid", nil),
  )
rescue KeyError => err
  p err
  p card_hash
end