class MtgDbClient::Client
Public Class Methods
new(options={})
click to toggle source
# File lib/MtgDbClient/client.rb, line 9 def initialize(options={}) merged_options = MtgDbClient.options.merge(options) Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", merged_options[key]) end self.class.base_uri 'api.mtgdb.info' end
Public Instance Methods
filter_cards(property, value)
click to toggle source
# File lib/MtgDbClient/client.rb, line 78 def filter_cards(property, value) self.class.get(URI.escape("/cards/?#{property}=#{value}")).map{|c| Card.new(c)} end
get_card(multiverse_id)
click to toggle source
Card
Functions
# File lib/MtgDbClient/client.rb, line 56 def get_card(multiverse_id) response = self.class.get("/cards/#{multiverse_id}") Card.new(response) end
get_card_by_name(card_name)
click to toggle source
# File lib/MtgDbClient/client.rb, line 74 def get_card_by_name(card_name) response = self.class.get(URI.escape("/cards/#{card_name.tr('/', '').tr(':','')}")).map{|c| Card.new(c)} end
get_card_in_set(set_id, collector_number)
click to toggle source
# File lib/MtgDbClient/client.rb, line 82 def get_card_in_set(set_id, collector_number) response = self.class.get(URI.escape("/sets/#{set_id.upcase}/cards/#{collector_number.to_s}")) Card.new(response) end
get_card_subtypes()
click to toggle source
# File lib/MtgDbClient/client.rb, line 28 def get_card_subtypes self.class.get("/cards/subtypes") end
get_card_types()
click to toggle source
# File lib/MtgDbClient/client.rb, line 24 def get_card_types self.class.get("/cards/types") end
get_cards()
click to toggle source
# File lib/MtgDbClient/client.rb, line 65 def get_cards self.class.get("/cards").map{|c| Card.new(c)} end
get_cards_by_id(multiverse_ids=[])
click to toggle source
# File lib/MtgDbClient/client.rb, line 61 def get_cards_by_id(multiverse_ids=[]) self.class.get(URI.escape("/cards/#{multiverse_ids.join(',')}")).map{|c| Card.new(c)} end
get_cards_in_set(set_id)
click to toggle source
# File lib/MtgDbClient/client.rb, line 51 def get_cards_in_set(set_id) self.class.get(URI.escape("/sets/#{set_id}/cards")).map{|c| Card.new(c)} end
get_random_card()
click to toggle source
# File lib/MtgDbClient/client.rb, line 69 def get_random_card response = self.class.get("/cards/random") Card.new(response) end
get_random_card_in_set(set_id)
click to toggle source
# File lib/MtgDbClient/client.rb, line 42 def get_random_card_in_set(set_id) response = self.class.get(URI.escape("/sets/#{set_id}/cards/random")) Card.new(response) end
get_rarity_types()
click to toggle source
Common Functions
# File lib/MtgDbClient/client.rb, line 20 def get_rarity_types self.class.get("/cards/rarity") end
get_set(set_id)
click to toggle source
# File lib/MtgDbClient/client.rb, line 37 def get_set(set_id) response = self.class.get(URI.escape("/sets/#{set_id}")) CardSet.new(response) end
get_sets()
click to toggle source
Set Functions
# File lib/MtgDbClient/client.rb, line 33 def get_sets self.class.get("/sets").map{|s| CardSet.new(s)} end
get_sets_by_id(set_ids=[])
click to toggle source
# File lib/MtgDbClient/client.rb, line 47 def get_sets_by_id(set_ids=[]) self.class.get(URI.escape("/sets/#{set_ids.join(',').upcase}")).map{|s| CardSet.new(s)} end
search(text, start=0, limit=0, isComplex=false)
click to toggle source
# File lib/MtgDbClient/client.rb, line 87 def search(text, start=0, limit=0, isComplex=false) if isComplex self.class.get(URI.escape("/search/?q=#{text}&start=#{start}&limit=#{limit}")).map{|c| Card.new(c)} else self.class.get(URI.escape("/search/#{text}?start=#{start}&limit=#{limit}")).map{|c| Card.new(c)} end end