Module: ZombieBattleground::Api::Extensions::Cards
- Included in:
- ZombieBattleground::Api::Extensions
- Defined in:
- lib/zombie_battleground/api/extensions/cards.rb
Overview
API Extensions for Cards
Instance Method Summary collapse
-
#all_cards(**args) ⇒ Enumerator
Returns an enumerator for all available cards, accepts a block for yields.
-
#card_factions ⇒ Array<String>
Fetches all card factions.
-
#card_kinds ⇒ Array<String>
Fetches all card kinds.
-
#card_ranks ⇒ Array<String>
Fetches all card ranks.
-
#card_rarities ⇒ Array<String>
Fetches all card rarities.
-
#card_sets ⇒ Array<String>
Fetches all card sets.
-
#card_types ⇒ Array<String>
Fetches all card types.
-
#cards_by_faction(faction) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected faction.
-
#cards_by_kind(kind) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected kind.
-
#cards_by_rank(rank) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected rank.
-
#cards_by_rarity(rarity) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected rarity.
-
#cards_by_set(set) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected set.
-
#cards_by_type(type) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected type.
Instance Method Details
#all_cards(**args) ⇒ Enumerator
Returns an enumerator for all available cards, accepts a block for yields
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 37 def all_cards(**args) args.delete(:limit) # query as many as possible return enum_for(:all_cards, args) unless block_given? page = 1 loop do response = @client.cards_request(args.merge(page: page)) response.cards.each { |card| yield card } break if response.cards.size < PAGE_MAX # :nocov: page += 1 # :nocov: end end |
#card_factions ⇒ Array<String>
Fetches all card factions
106 107 108 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 106 def card_factions load_cards_data['factions'] end |
#card_kinds ⇒ Array<String>
Fetches all card kinds
64 65 66 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 64 def card_kinds load_cards_data['kinds'] end |
#card_ranks ⇒ Array<String>
Fetches all card ranks
78 79 80 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 78 def card_ranks load_cards_data['ranks'] end |
#card_rarities ⇒ Array<String>
Fetches all card rarities
134 135 136 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 134 def card_rarities load_cards_data['rarities'] end |
#card_sets ⇒ Array<String>
Fetches all card sets
92 93 94 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 92 def card_sets load_cards_data['sets'] end |
#card_types ⇒ Array<String>
Fetches all card types
120 121 122 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 120 def card_types load_cards_data['types'] end |
#cards_by_faction(faction) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected faction
198 199 200 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 198 def cards_by_faction(faction) all_cards(set: faction).to_a end |
#cards_by_kind(kind) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected kind
150 151 152 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 150 def cards_by_kind(kind) all_cards(kind: kind).to_a end |
#cards_by_rank(rank) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected rank
166 167 168 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 166 def cards_by_rank(rank) all_cards(rank: rank).to_a end |
#cards_by_rarity(rarity) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected rarity
230 231 232 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 230 def cards_by_rarity(rarity) all_cards(rarity: rarity).to_a end |
#cards_by_set(set) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected set
182 183 184 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 182 def cards_by_set(set) all_cards(set: set).to_a end |
#cards_by_type(type) ⇒ Array<ZombieBattleground::Api::Models::Card>
Fetches all cards with selected type
214 215 216 |
# File 'lib/zombie_battleground/api/extensions/cards.rb', line 214 def cards_by_type(type) all_cards(type: type).to_a end |