tolarian_registry 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2933f7c4a114480105ea53fcab53a1fbaab7328
4
- data.tar.gz: 8682e0d281b7c7ab2cf15d731b9c4129d37eb9f0
3
+ metadata.gz: e20dbab81f275de9f947980f61cf10fd246e7517
4
+ data.tar.gz: 75f85ad22d106f0f79d55d3df24234f5442417bc
5
5
  SHA512:
6
- metadata.gz: d71e822ef59f4d7fcbdd5767db8bc8719c3ce6c8246e4d236ed52a935330c6144bfcac784fce11a0a021705015292e56daf3f804bb7e53a936d3d47fd8f9c31d
7
- data.tar.gz: a2d79ab047e82a89dd8cd42617c4921c10ca1b4af113a2beadddfc1807e222579843b8b96b1f92a95f2bb6323813d64f4250ac1773d0262389f52aceb2ea2d65
6
+ metadata.gz: d39f1afc6a057022c17d890a5fabea3e62f5d55a5bd23f622132c97c9875417bf1dc92b25b49a6745aac5ed33815f4ffc4590a5d392d989582e8c243918b8754
7
+ data.tar.gz: 3c1d7c90b9c62f2fc7f4415aaef03e8089c4248ab70c3c3e95d599558313d5f6c90bed778073056185d455253251ad7aed2524fc9af9f4f41e053f37de6458e6
@@ -1,24 +1,59 @@
1
1
  require "tolarian_registry/version"
2
+ require 'unirest'
2
3
 
3
4
  module TolarianRegistry
4
- class Registry
5
- attr_accessor :card, :set
5
+ class Card
6
+ attr_accessor :multiverse_id, :related_card_id, :set_number, :card_name, :search_name, :description, :flavor, :colors, :mana_cost, :converted_mana_cost, :card_set_name, :card_type, :card_subtype, :power, :toughness, :loyalty, :rarity, :artist, :card_set_id, :token, :promo, :rulings, :formats, :released_at
6
7
 
7
- def initialize(options = {})
8
- @card = options || ''
9
- @set = options || ''
8
+ def initialize(hash)
9
+ @multiverse_id = hash[:multiverse_id]
10
+ api_hash = Unirest.get("http://api.mtgdb.info/cards/#{@multiverse_id}").body
11
+ @related_card_id = api_hash["relatedCardId"]
12
+ @set_number = api_hash["setNumber"]
13
+ @card_name = api_hash["name"]
14
+ @search_name = api_hash["searchName"]
15
+ @description = api_hash["description"]
16
+ @flavor = api_hash["flavor"]
17
+ @colors = api_hash["colors"]
18
+ @mana_cost = api_hash["manaCost"]
19
+ @converted_mana_cost = api_hash["convertedManaCost"]
20
+ @card_set_name = api_hash["cardSetName"]
21
+ @card_type = api_hash["type"]
22
+ @card_subtype = api_hash["subType"]
23
+ @power = api_hash["power"]
24
+ @toughness = api_hash["toughness"]
25
+ @loyalty = api_hash["loyalty"]
26
+ @rarity = api_hash["rarity"]
27
+ @artist = api_hash["artist"]
28
+ @card_set_id = api_hash["cardSetId"]
29
+ @token = api_hash["token"]
30
+ @promo = api_hash["promo"]
31
+ @rulings = api_hash["rulings"]
32
+ @formats = api_hash["formats"]
33
+ @released_at = api_hash["releasedAt"]
10
34
  end
11
35
 
12
- def tcgplayer_price(card, set)
13
- @card = Unirest.get("http://magictcgprices.appspot.com/api/tcgplayer/price.json?cardname=#{card}&cardset=#{set}").body
36
+ def low_price
37
+ @price = get_price("low")
14
38
  end
15
39
 
16
- def cfb_price(card, set)
17
- @card = Unirest.get("http://magictcgprices.appspot.com/api/cfb/price.json?cardname=#{card}&cardset=#{set}").body
40
+ def median_price
41
+ @price = get_price("median")
18
42
  end
19
43
 
20
- def ebay_price(card, set)
21
- @card = Unirest.get("http://magictcgprices.appspot.com/api/ebay/price.json?cardname=#{card}&cardset=#{set}").body
44
+ def high_price
45
+ @price = get_price("high")
22
46
  end
47
+
48
+ private
49
+
50
+ def get_price(level)
51
+ @card = Unirest.get("https://api.deckbrew.com/mtg/cards?multiverseid=#{@multiverse_id}").body
52
+ @card[0]["editions"].each do |edition|
53
+ @price = edition["price"][level] if edition["multiverse_id"] == @multiverse_id
54
+ end
55
+ @price
56
+ end
57
+
23
58
  end
24
59
  end
@@ -1,3 +1,3 @@
1
1
  module TolarianRegistry
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tolarian_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - walshification
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-23 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unirest