class Scryfall::API

Public Class Methods

new(url = 'https://api.scryfall.com') click to toggle source
# File lib/scryfall/api.rb, line 9
def initialize(url = 'https://api.scryfall.com');
  @url = url
end

Public Instance Methods

get(path = "", params = {}, **args) click to toggle source
# File lib/scryfall/api.rb, line 13
def get(path = "", params = {}, **args)
  res = HTTP.get(mount_uri(path), params: params)

  if args.has_key?(:to_struct) && args[:to_struct] == true
    JSON.parse res, object_class: OpenStruct
  else
    JSON.parse res
  end
end

Private Instance Methods

mount_uri(path) click to toggle source
# File lib/scryfall/api.rb, line 25
def mount_uri(path)
  @url + path
end