tolarian_registry 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tolarian_registry.rb +46 -11
- data/lib/tolarian_registry/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e20dbab81f275de9f947980f61cf10fd246e7517
|
4
|
+
data.tar.gz: 75f85ad22d106f0f79d55d3df24234f5442417bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d39f1afc6a057022c17d890a5fabea3e62f5d55a5bd23f622132c97c9875417bf1dc92b25b49a6745aac5ed33815f4ffc4590a5d392d989582e8c243918b8754
|
7
|
+
data.tar.gz: 3c1d7c90b9c62f2fc7f4415aaef03e8089c4248ab70c3c3e95d599558313d5f6c90bed778073056185d455253251ad7aed2524fc9af9f4f41e053f37de6458e6
|
data/lib/tolarian_registry.rb
CHANGED
@@ -1,24 +1,59 @@
|
|
1
1
|
require "tolarian_registry/version"
|
2
|
+
require 'unirest'
|
2
3
|
|
3
4
|
module TolarianRegistry
|
4
|
-
class
|
5
|
-
attr_accessor :
|
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(
|
8
|
-
@
|
9
|
-
|
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
|
13
|
-
@
|
36
|
+
def low_price
|
37
|
+
@price = get_price("low")
|
14
38
|
end
|
15
39
|
|
16
|
-
def
|
17
|
-
@
|
40
|
+
def median_price
|
41
|
+
@price = get_price("median")
|
18
42
|
end
|
19
43
|
|
20
|
-
def
|
21
|
-
@
|
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
|
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.
|
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-
|
11
|
+
date: 2014-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unirest
|