Class: MTG::Set

Inherits:
Object
  • Object
show all
Includes:
RestClient, SetRepresenter, Roar::JSON
Defined in:
lib/mtg_sdk/set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from RestClient

get

Instance Attribute Details

#blockObject

Returns the value of attribute block.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def block
  @block
end

#boosterObject

Returns the value of attribute booster.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def booster
  @booster
end

#borderObject

Returns the value of attribute border.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def border
  @border
end

#codeObject

Returns the value of attribute code.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def code
  @code
end

#gatherer_codeObject

Returns the value of attribute gatherer_code.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def gatherer_code
  @gatherer_code
end

#magic_cards_info_codeObject

Returns the value of attribute magic_cards_info_code.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def magic_cards_info_code
  @magic_cards_info_code
end

#mkm_idObject

Returns the value of attribute mkm_id.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def mkm_id
  @mkm_id
end

#mkm_nameObject

Returns the value of attribute mkm_name.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def mkm_name
  @mkm_name
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def name
  @name
end

#old_codeObject

Returns the value of attribute old_code.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def old_code
  @old_code
end

#online_onlyObject

Returns the value of attribute online_only.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def online_only
  @online_only
end

#release_dateObject

Returns the value of attribute release_date.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def release_date
  @release_date
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/mtg_sdk/set.rb', line 11

def type
  @type
end

Class Method Details

.allArray<Set>

Get all sets from a query

Returns:

  • (Array<Set>)

    Array of Set objects



33
34
35
# File 'lib/mtg_sdk/set.rb', line 33

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

.find(code) ⇒ Set

Find a single set by the set code

Parameters:

  • code (String)

    the Set code

Returns:

  • (Set)

    a Set object



26
27
28
# File 'lib/mtg_sdk/set.rb', line 26

def self.find(code)
  QueryBuilder.new(Set).find(code)
end

.generate_booster(code) ⇒ Array<Card>

Returns Array of Card objects.

Parameters:

  • code (String)

    the Set code

Returns:

  • (Array<Card>)

    Array of Card objects



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mtg_sdk/set.rb', line 49

def self.generate_booster(code)
  cards = []
  response = RestClient.get("sets/#{code}/booster")
  data = response.body['cards']
  
  data.each do |card|
    cards << Card.new.from_json(card.to_json)
  end
  
  cards
end

.Resourcestring

Get the resource string

Returns:

  • (string)

    The API resource string



18
19
20
# File 'lib/mtg_sdk/set.rb', line 18

def self.Resource
  "sets"
end

.where(args) ⇒ QueryBuilder

Adds a parameter to the hash of query parameters

Parameters:

  • args (Hash)

    the query parameter

Returns:



41
42
43
# File 'lib/mtg_sdk/set.rb', line 41

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