Class: HearthstoneJSON

Inherits:
Object
  • Object
show all
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

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(options = {})
  get_json('/cardbacks.json', options)
end

#cards(include_uncollectible = false, options = {}) ⇒ Object



27
28
29
30
# File 'lib/hearthstone_json.rb', line 27

def cards(include_uncollectible = false, options = {})
  return get_json('/cards.json', options) if include_uncollectible
  get_json('/cards.collectible.json', options)
end

#enums(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/hearthstone_json.rb', line 14

def enums(options = {})
  JSON.parse(
    HTTParty.get(
      URI.escape("#{API_URL_BASE}/#{API_VER}/enums.json"),
      options
    ).body
  )
end