Class: HearthstoneJSON
- Inherits:
-
Object
- Object
- HearthstoneJSON
- Includes:
- HTTParty
- Defined in:
- lib/hearthstone_json.rb
Overview
HearthstoneJSON Class
Constant Summary collapse
- API_URL_BASE =
'https://api.hearthstonejson.com'.freeze
- API_VER =
'v1'.freeze
Instance Method Summary collapse
- #cardbacks(options = {}) ⇒ Object
- #cards(include_uncollectible = false, options = {}) ⇒ Object
- #enums(options = {}) ⇒ Object
-
#initialize(data_ver = 'latest', locale = 'enUS') ⇒ HearthstoneJSON
constructor
A new instance of HearthstoneJSON.
Constructor Details
#initialize(data_ver = 'latest', locale = 'enUS') ⇒ HearthstoneJSON
Returns a new instance of HearthstoneJSON.
10 11 12 |
# File 'lib/hearthstone_json.rb', line 10 def initialize(data_ver = 'latest', locale = 'enUS') self.class.base_uri "#{API_URL_BASE}/#{API_VER}/#{data_ver}/#{locale}" end |
Instance Method Details
#cardbacks(options = {}) ⇒ Object
23 24 25 |
# File 'lib/hearthstone_json.rb', line 23 def cardbacks( = {}) get_json('/cardbacks.json', ) end |
#cards(include_uncollectible = false, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/hearthstone_json.rb', line 27 def cards(include_uncollectible = false, = {}) return get_json('/cards.json', ) if include_uncollectible get_json('/cards.collectible.json', ) end |
#enums(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/hearthstone_json.rb', line 14 def enums( = {}) JSON.parse( HTTParty.get( URI.escape("#{API_URL_BASE}/#{API_VER}/enums.json"), ).body ) end |