Class: Pokemon::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/pokemon_tcg_sdk/card.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#abilitiesObject

Returns the value of attribute abilities.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def abilities
  @abilities
end

#ancient_traitObject

Returns the value of attribute ancient_trait.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def ancient_trait
  @ancient_trait
end

#artistObject

Returns the value of attribute artist.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def artist
  @artist
end

#attacksObject

Returns the value of attribute attacks.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def attacks
  @attacks
end

#cardmarketObject

Returns the value of attribute cardmarket.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def cardmarket
  @cardmarket
end

#converted_retreat_costObject

Returns the value of attribute converted_retreat_cost.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def converted_retreat_cost
  @converted_retreat_cost
end

#evolves_fromObject

Returns the value of attribute evolves_from.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def evolves_from
  @evolves_from
end

#evolves_toObject

Returns the value of attribute evolves_to.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def evolves_to
  @evolves_to
end

#flavor_textObject

Returns the value of attribute flavor_text.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def flavor_text
  @flavor_text
end

#hpObject

Returns the value of attribute hp.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def hp
  @hp
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def id
  @id
end

#imagesObject

Returns the value of attribute images.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def images
  @images
end

#legalitiesObject

Returns the value of attribute legalities.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def legalities
  @legalities
end

#levelObject

Returns the value of attribute level.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def level
  @level
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def name
  @name
end

#national_pokedex_numbersObject

Returns the value of attribute national_pokedex_numbers.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def national_pokedex_numbers
  @national_pokedex_numbers
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def number
  @number
end

#rarityObject

Returns the value of attribute rarity.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def rarity
  @rarity
end

#regulation_markObject

Returns the value of attribute regulation_mark.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def regulation_mark
  @regulation_mark
end

#resistancesObject

Returns the value of attribute resistances.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def resistances
  @resistances
end

#retreat_costObject

Returns the value of attribute retreat_cost.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def retreat_cost
  @retreat_cost
end

#rulesObject

Returns the value of attribute rules.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def rules
  @rules
end

#setObject

Returns the value of attribute set.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def set
  @set
end

#subtypesObject

Returns the value of attribute subtypes.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def subtypes
  @subtypes
end

#supertypeObject

Returns the value of attribute supertype.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def supertype
  @supertype
end

#tcgplayerObject

Returns the value of attribute tcgplayer.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def tcgplayer
  @tcgplayer
end

#typesObject

Returns the value of attribute types.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def types
  @types
end

#weaknessesObject

Returns the value of attribute weaknesses.



5
6
7
# File 'lib/pokemon_tcg_sdk/card.rb', line 5

def weaknesses
  @weaknesses
end

Class Method Details

.allArray<Card>

Get all cards from a query by paging through data

Returns:

  • (Array<Card>)

    Array of Card objects



60
61
62
# File 'lib/pokemon_tcg_sdk/card.rb', line 60

def self.all
  QueryBuilder.new(Card).all
end

.find(id) ⇒ Card

Find a single card by the card id

Parameters:

  • id (String)

    the card id

Returns:

  • (Card)

    the Card object response



53
54
55
# File 'lib/pokemon_tcg_sdk/card.rb', line 53

def self.find(id)
  QueryBuilder.new(Card).find(ERB::Util.url_encode(id))
end

.from_json(json) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pokemon_tcg_sdk/card.rb', line 9

def self.from_json(json)
  card = Card.new
  card.id = json['id']
  card.name = json['name']
  card.supertype = json['supertype']
  card.subtypes = json['subtypes']
  card.level = json['level']
  card.hp = json['hp']
  card.types = json['types']
  card.evolves_from = json['evolvesFrom']
  card.evolves_to = json['evolvesTo']
  card.rules = json['rules']
  card.ancient_trait = AncientTrait.from_json(json['ancientTrait']) if !json['ancientTrait'].nil?
  card.abilities = json['abilities'].map {|ability_json| Ability.from_json(ability_json)} if !json['abilities'].nil?
  card.attacks = json['attacks'].map {|attack_json| Attack.from_json(attack_json)} if !json['attacks'].nil?
  card.weaknesses = json['weaknesses'].map {|weakness_json| Weakness.from_json(weakness_json)} if !json['weaknesses'].nil?
  card.resistances = json['resistances'].map {|resistance_json| Resistance.from_json(resistance_json)} if !json['resistances'].nil?
  card.retreat_cost = json['retreatCost']
  card.converted_retreat_cost = json['convertedRetreatCost']
  card.set = Set.from_json(json['set']) if !json['set'].nil?
  card.number = json['number']
  card.artist = json['artist']
  card.rarity = json['rarity']
  card.flavor_text = json['flavorText']
  card.national_pokedex_numbers = json['nationalPokedexNumbers']
  card.legalities = Legalities.from_json(json['legalities']) if !json['legalities'].nil?
  card.regulation_mark = json['regulationMark']
  card.tcgplayer = Tcgplayer.from_json(json['tcgplayer']) if !json['tcgplayer'].nil?
  card.cardmarket = Cardmarket.from_json(json['cardmarket']) if !json['cardmarket'].nil?
  card.images = CardImages.from_json(json['images']) if !json['images'].nil?
  card
end

.ResourceString

Get the resource string

Returns:

  • (String)

    The API resource string



45
46
47
# File 'lib/pokemon_tcg_sdk/card.rb', line 45

def self.Resource
  "cards"
end

.where(args) ⇒ Array<Card>

Adds a parameter to the hash of query parameters

Parameters:

  • args (Hash)

    the query parameter

Returns:

  • (Array<Card>)

    Array of Card objects



68
69
70
# File 'lib/pokemon_tcg_sdk/card.rb', line 68

def self.where(args)
  QueryBuilder.new(Card).where(args)
end