Class: TCGPlayerSDK::Pokemon
- Inherits:
- 
      Object
      
        - Object
- TCGPlayerSDK::Pokemon
 
- Defined in:
- lib/tcg-player-sdk/pokemon.rb
Overview
Helpers for pokemon-centric tasks
Instance Attribute Summary collapse
- 
  
    
      #tcg  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute tcg. 
Instance Method Summary collapse
- #category ⇒ Object
- #categoryId ⇒ Object
- 
  
    
      #initialize(_tcg)  ⇒ Pokemon 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Pokemon. 
- #manifest ⇒ Object
- 
  
    
      #set(set_name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns the TCGPlayerSDK filter item corresponding to the input set. 
- 
  
    
      #sets  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns the TCGPlaeryAPI filter corresponding to Sets. 
- 
  
    
      #sorting  ⇒ Array<TCGPlayerSDK::ResponseStruct> 
    
    
  
  
  
  
  
  
  
  
  
    the available ways to sort search data. 
Constructor Details
#initialize(_tcg) ⇒ Pokemon
Returns a new instance of Pokemon.
| 5 6 7 8 | # File 'lib/tcg-player-sdk/pokemon.rb', line 5 def initialize(_tcg) self.tcg = _tcg @category = nil end | 
Instance Attribute Details
#tcg ⇒ Object
Returns the value of attribute tcg.
| 3 4 5 | # File 'lib/tcg-player-sdk/pokemon.rb', line 3 def tcg @tcg end | 
Instance Method Details
#category ⇒ Object
| 10 11 12 | # File 'lib/tcg-player-sdk/pokemon.rb', line 10 def category @category ||= tcg.categories(limit: 100).select{|c| c.name =~ /Pokemon/i}.first end | 
#categoryId ⇒ Object
| 14 15 16 | # File 'lib/tcg-player-sdk/pokemon.rb', line 14 def categoryId category.categoryId end | 
#manifest ⇒ Object
| 18 19 20 | # File 'lib/tcg-player-sdk/pokemon.rb', line 18 def manifest @manifest ||= tcg.category_search_manifest(categoryId) end | 
#set(set_name) ⇒ Object
Returns the TCGPlayerSDK filter item corresponding to the input set
pokemon.set('Base Set')
[
    [0] TCGPlayerSDK::ResponseStruct {
         :text => "Base Set",
        :value => "Base Set"
    }
]
| 45 46 47 | # File 'lib/tcg-player-sdk/pokemon.rb', line 45 def set(set_name) sets.items.select{|i| i.text == set_name} end | 
#sets ⇒ Object
Returns the TCGPlaeryAPI filter corresponding to Sets
| 24 25 26 | # File 'lib/tcg-player-sdk/pokemon.rb', line 24 def sets @set_filter ||= @manifest.results.first.filters.select{|f| f.name == 'SetName'}.first end | 
#sorting ⇒ Array<TCGPlayerSDK::ResponseStruct>
the available ways to sort search data. Set :sort in your search parameters to one of the returned :value
| 31 32 33 | # File 'lib/tcg-player-sdk/pokemon.rb', line 31 def sorting @sorting ||= @manifest.results.first.sorting end |