Class: Scryfall::API
- Inherits:
-
Object
- Object
- Scryfall::API
- Defined in:
- lib/scryfall/api.rb
Instance Method Summary collapse
- #get(path = "", params = {}, **args) ⇒ Object
-
#initialize(url = 'https://api.scryfall.com') ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(url = 'https://api.scryfall.com') ⇒ API
Returns a new instance of API.
9 10 11 |
# File 'lib/scryfall/api.rb', line 9 def initialize(url = 'https://api.scryfall.com'); @url = url end |
Instance Method Details
#get(path = "", params = {}, **args) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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 |