Method: Deckstrings::Deck.decode

Defined in:
lib/deckstrings/deckstrings.rb

.decode(deckstring) ⇒ Deck

Decodes a Hearthstone deckstring into a Deckstrings::Deck with basic hero and card metadata.

This method validates the well-formedness of the deckstring, the embedded version, the format, card counts, and each hero/card ID.

All IDs refer to unique Hearthstone DBF IDs which can be used in conjunction with HearthstoneJSON metadata.

Examples:

deck = Deckstrings::Deck.decode('AAEBAf0GAA/yAaIC3ALgBPcE+wWKBs4H2QexCMII2Q31DfoN9g4A')
deck = Deckstrings::Deck.decode('AAECAZICCPIF+Az5DK6rAuC7ApS9AsnHApnTAgtAX/4BxAbkCLS7Asu8As+8At2+AqDNAofOAgA=')

Parameters:

  • deckstring (String)

    Base64-encoded Hearthstone deckstring.

Returns:

  • (Deck)

    Decoded Hearthstone deck.

Raises:

  • (FormatError)

    If the deckstring is malformed or contains invalid deck data.

See Also:



335
336
337
338
339
340
341
342
# File 'lib/deckstrings/deckstrings.rb', line 335

def self.decode(deckstring)
  parts = Deckstrings::decode(deckstring)
  begin
    Deck.new(parts)
  rescue ArgumentError => e
    raise FormatError, e.to_s
  end
end