class TolarianRegistry::Card

Attributes

artist[RW]
card_name[RW]
card_set_id[RW]
card_set_name[RW]
card_subtype[RW]
card_type[RW]
colors[RW]
converted_mana_cost[RW]
description[RW]
flavor[RW]
formats[RW]
loyalty[RW]
mana_cost[RW]
multiverse_id[RW]
power[RW]
promo[RW]
rarity[RW]
released_at[RW]
rulings[RW]
search_name[RW]
set_number[RW]
token[RW]
toughness[RW]

Public Class Methods

new(hash) click to toggle source
# File lib/tolarian_registry.rb, line 8
def initialize(hash)
  @multiverse_id = hash[:multiverse_id]
  api_hash = Unirest.get("http://api.mtgdb.info/cards/#{@multiverse_id}").body
  @related_card_id = api_hash["relatedCardId"]
  @set_number = api_hash["setNumber"]
  @card_name = api_hash["name"]
  @search_name = api_hash["searchName"]
  @description = api_hash["description"]
  @flavor = api_hash["flavor"]
  @colors = api_hash["colors"]
  @mana_cost = api_hash["manaCost"]
  @converted_mana_cost = api_hash["convertedManaCost"]
  @card_set_name = api_hash["cardSetName"]
  @card_type = api_hash["type"]
  @card_subtype = api_hash["subType"]
  @power = api_hash["power"]
  @toughness = api_hash["toughness"]
  @loyalty = api_hash["loyalty"]
  @rarity = api_hash["rarity"]
  @artist = api_hash["artist"]
  @card_set_id = api_hash["cardSetId"]
  @token = api_hash["token"]
  @promo = api_hash["promo"]
  @rulings = api_hash["rulings"]
  @formats = api_hash["formats"]
  @released_at = api_hash["releasedAt"]
end

Public Instance Methods

high_price() click to toggle source
# File lib/tolarian_registry.rb, line 44
def high_price
  @price = get_price("high")
end
low_price() click to toggle source
# File lib/tolarian_registry.rb, line 36
def low_price
  @price = get_price("low")
end
median_price() click to toggle source
# File lib/tolarian_registry.rb, line 40
def median_price
  @price = get_price("median")
end

Private Instance Methods

get_price(level) click to toggle source
# File lib/tolarian_registry.rb, line 50
def get_price(level)
  @card = Unirest.get("https://api.deckbrew.com/mtg/cards?multiverseid=#{@multiverse_id}").body
  @card[0]["editions"].each do |edition|
    @price = edition["price"][level] if edition["multiverse_id"] == @multiverse_id
  end
  @price
end