class HearthstoneJSON

HearthstoneJSON Class

Constants

API_URL_BASE
API_VER

Attributes

locale[RW]

Public Class Methods

new(data_ver = 'latest', locale = 'enUS') click to toggle source
# 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

Public Instance Methods

cardbacks(options = {}) click to toggle source
# File lib/hearthstone_json.rb, line 23
def cardbacks(options = {})
  get_json('/cardbacks.json', options)
end
cards(include_uncollectible = false, options = {}) click to toggle source
# 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 = {}) click to toggle source
# 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

Private Instance Methods

get_json(path, options = {}) click to toggle source
# File lib/hearthstone_json.rb, line 36
def get_json(path, options = {})
  response = self.class.get(URI.escape(path), options)
  JSON.parse(response.body)
end