Class: Scryfall::Set

Inherits:
Client show all
Defined in:
lib/scryfall/set.rb

Class Method Summary collapse

Methods inherited from Client

#connection, connection, connection=, #initialize, #method_missing, #to_h

Constructor Details

This class inherits a constructor from Scryfall::Client

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Scryfall::Client

Class Method Details

.all(format: "json", pretty: false) ⇒ Object

Returns a List object of all Sets on Scryfall scryfall.com/docs/api/sets/all

Parameters:

  • format (String) (defaults to: "json")

    The data format to return. This method only supports json.

  • pretty (Boolean) (defaults to: false)

    If true, the returned JSON will be prettified. Avoid using for production code.



12
13
14
15
16
17
18
19
# File 'lib/scryfall/set.rb', line 12

def all(format: "json", pretty: false)
  req = Request.new(
      params: {format: format, pretty: pretty},
      headers: nil,
      body: nil)

  Scryfall::Search.get("/sets", self, req)
end

.code(code, format: "json", pretty: false) ⇒ Object

Returns a Set with the given set code. The code can be either the code or the mtgo_code for the set. scryfall.com/docs/api/sets/code

Parameters:

  • code (String)

    The three to five letter set code

  • format (String) (defaults to: "json")

    The data format to return. This method only supports json.

  • pretty (Boolean) (defaults to: false)

    If true, the returned JSON will be prettified. Avoid using for production code.



27
28
29
30
31
32
33
34
# File 'lib/scryfall/set.rb', line 27

def code(code, format: "json", pretty: false)
  req = Request.new(
      params: {format: format, pretty: pretty},
      headers: nil,
      body: nil)

  Scryfall::Set.new JSON.parse(connection.get("/sets/#{code}", req).body)
end

.id(id, format: "json", pretty: false) ⇒ Object

Returns a Set with the given Scryfall ID. scryfall.com/docs/api/sets/id

Parameters:

  • id (String)

    The Scryfall set ID

  • format (String) (defaults to: "json")

    The data format to return. This method only supports json.

  • pretty (Boolean) (defaults to: false)

    If true, the returned JSON will be prettified. Avoid using for production code.



42
43
44
45
46
47
48
49
# File 'lib/scryfall/set.rb', line 42

def id(id, format: "json", pretty: false)
  req = Request.new(
      params: {format: format, pretty: pretty},
      headers: nil,
      body: nil)

  Scryfall::Set.new JSON.parse(connection.get("/sets/#{id}", req).body)
end