runeterra_cards 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 275e8ca4e8362b65da7022dc3042e9fbe3b0970f52443e652476757be52125f1
4
- data.tar.gz: ab803e005acf47f9499aad38aaad76d0e1c59c275dc4457bc8735208f08baace
3
+ metadata.gz: a7a06c2e4f2c76ba4038979ac6215010fb95b763da60717bc18faec557d41dcb
4
+ data.tar.gz: 1583f4620c7ccc60f3f2d18ed5646f2c9e2d38691cd191340dc70db9de9012ec
5
5
  SHA512:
6
- metadata.gz: f406aad97cd4b6b57b356f08ff665661d3edecd608467b0a04b2c76d434927bc406cd01fec7f02aa171701f0a0f89fd2e322de7cbc871d18cb58993c9ae4d9e3
7
- data.tar.gz: 96023313de8c2868fbf551185224a9441a13e30ddb297f9766b69b07481f4d21c1a56b78052ec09ba3a5aa22878c39f1c94ef196a235838b5cc447bb08255d96
6
+ metadata.gz: 571ad2f19f35022cdc41f9b0195b7a87b70e6f6cb7f75438e16a6e7e891355c1615debf359dd59c0717abe7cb7125adfde5e8a54b076dcecf45389364df6827b
7
+ data.tar.gz: b5414fa7da1d020f6ec6eec394e66fa1735f264a60e850be18e8f5dba303959e5f517a3bbb6d0edbb1734867d619b432c7cbeb5a6bebc461c33946d7634fc692
@@ -23,7 +23,7 @@ module RuneterraCards
23
23
  @code = code
24
24
  else
25
25
  padded_set = format('%<i>02d', i: set)
26
- faction = FACTION_IDENTIFIERS_FROM_INT.fetch(faction_number)
26
+ faction = FACTION_IDENTIFIERS_FROM_INT.fetch(faction_number) { |key| raise UnrecognizedFactionError, key }
27
27
  padded_card_number = format('%<i>03d', i: card_number)
28
28
  @code = "#{padded_set}#{faction}#{padded_card_number}"
29
29
  end
@@ -29,9 +29,31 @@ module RuneterraCards
29
29
  # issue relating to this. If none exists, then file one!
30
30
  # @see SUPPORTED_VERSION
31
31
  class UnrecognizedVersionError < DeckCodeParseError
32
+ # @return [Fixnum] the version number encountered in the deck code
33
+ attr_accessor :version
34
+
32
35
  def initialize(expected, got)
33
36
  super("Unrecognized deck code version number: #{got}, was expecting: #{expected}. \
34
37
  Possibly an invalid deck code, possibly you need to update the deck code library version.")
38
+ @version = got
39
+ end
40
+ end
41
+
42
+ # This exception is raised if the deck code contains an unexpected faction number. (see the table at
43
+ # {https://github.com/RiotGames/LoRDeckCodes} for what 'faction number' means.) This most likely means that
44
+ # Legends of Runeterra has a new faction and you need to update to a newer version of this library to handle it.
45
+ #
46
+ # Check that the {#faction_number} causing issues is listed in {https://github.com/RiotGames/LoRDeckCodes
47
+ # the table on Github}. If it isn't then something else has gone wrong. If it is, and updating this library doesn't
48
+ # fix the issue, then the library needs updating - {https://github.com/zofrex/runeterra_cards/issues file an issue}.
49
+ class UnrecognizedFactionError < DeckCodeParseError
50
+ # @return [Fixnum] the faction number that was unrecognized
51
+ attr_reader :faction_number
52
+
53
+ def initialize(faction_number)
54
+ super("Unrecognized faction number '#{faction_number}'."\
55
+ ' Possibly you need to update this library to a newer version')
56
+ @faction_number = faction_number
35
57
  end
36
58
  end
37
59
 
@@ -1,11 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RuneterraCards
4
- # An array of the two-letter Faction identifiers, indexed by their integer identifiers
4
+ # An map from integer faction identifiers to their two-letter identifiers
5
5
  # @example
6
6
  # FACTION_IDENTIFIERS_FROM_INT[2] #=> "IO"
7
- # @return [Array<String>]
8
- FACTION_IDENTIFIERS_FROM_INT = %w[DE FR IO NX PZ SI BW].freeze
7
+ # @return [Hash<Fixnum,String>]
8
+ FACTION_IDENTIFIERS_FROM_INT = {
9
+ 0 => 'DE',
10
+ 1 => 'FR',
11
+ 2 => 'IO',
12
+ 3 => 'NX',
13
+ 4 => 'PZ',
14
+ 5 => 'SI',
15
+ 6 => 'BW',
16
+ 9 => 'MT',
17
+ }.freeze
9
18
 
10
19
  # A map from two-letter Faction identifiers to their integer identifiers
11
20
  # @example
@@ -19,5 +28,6 @@ module RuneterraCards
19
28
  'PZ' => 4,
20
29
  'SI' => 5,
21
30
  'BW' => 6,
31
+ 'MT' => 9,
22
32
  }.freeze
23
33
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RuneterraCards
4
4
  # The version of this library
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeterra_cards
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zofrex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2020-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base32