Class: Scryfall::Catalog

Inherits:
Client
  • Object
show all
Defined in:
lib/scryfall/catalog.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

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

Constructor Details

#initialize(contents) ⇒ Catalog

Returns a new instance of Catalog.



6
7
8
9
10
# File 'lib/scryfall/catalog.rb', line 6

def initialize(contents)
  @uri = contents["uri"]
  @total_values = contents["total_values"]
  @data = contents["data"]
end

Dynamic Method Handling

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/scryfall/catalog.rb', line 4

def data
  @data
end

#total_valuesObject (readonly)

Returns the value of attribute total_values.



4
5
6
# File 'lib/scryfall/catalog.rb', line 4

def total_values
  @total_values
end

#uriObject (readonly)

Returns the value of attribute uri.



4
5
6
# File 'lib/scryfall/catalog.rb', line 4

def uri
  @uri
end

Class Method Details

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

Returns a Catalog of all artifact types in Scryfall’s database scryfall.com/docs/api/catalogs/artifact-types

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.



73
74
75
# File 'lib/scryfall/catalog.rb', line 73

def artifact_types(format: "json", pretty: false)
  request_catalogue("/catalog/artifact-types", format, pretty)
end

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

Returns a Catalog of all canonical artist names in Scryfall’s database. scryfall.com/docs/api/catalogs/artist-names

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.



28
29
30
# File 'lib/scryfall/catalog.rb', line 28

def artist_names(format: "json", pretty: false)
  request_catalogue("/catalog/artist-names", format, pretty)
end

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

Returns a Catalog of all nontoken English card names in Scryfall’s database.V scryfall.com/docs/api/catalogs/card-names

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.



19
20
21
# File 'lib/scryfall/catalog.rb', line 19

def card_names(format: "json", pretty: false)
  request_catalogue("/catalog/card-names", format, pretty)
end

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

Returns a Catalog of all creature types in Scryfall’s database. scryfall.com/docs/api/catalogs/creature-types

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.



46
47
48
# File 'lib/scryfall/catalog.rb', line 46

def creature_types(format: "json", pretty: false)
  request_catalogue("/catalog/creature-types", format, pretty)
end

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

Returns a Catalog of all enchantment types in Scryfall’s database scryfall.com/docs/api/catalogs/enchantment-types

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.



82
83
84
# File 'lib/scryfall/catalog.rb', line 82

def enchantment_types(format: "json", pretty: false)
  request_catalogue("/catalog/enchantment-types", format, pretty)
end

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

Returns a Catalog of all land types in Scryfall’s database scryfall.com/docs/api/catalogs/land-types

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.



64
65
66
# File 'lib/scryfall/catalog.rb', line 64

def land_types(format: "json", pretty: false)
  request_catalogue("/catalog/land-types", format, pretty)
end

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

Returns a Catalog of all possible values for a planeswalker’s loyalty in Scryfall’s database scryfall.com/docs/api/catalogs/loyalties

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.



118
119
120
# File 'lib/scryfall/catalog.rb', line 118

def loyalties(format: "json", pretty: false)
  request_catalogue("/catalog/loyalties", format, pretty)
end

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

Returns a Catalog of all planeswalker types in Scryfall’s database scryfall.com/docs/api/catalogs/planeswalker-types

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.



55
56
57
# File 'lib/scryfall/catalog.rb', line 55

def planeswalker_types(format: "json", pretty: false)
  request_catalogue("/catalog/planeswalker-types", format, pretty)
end

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

Returns a Catalog of all possible values for a creature or vehicle’s power in Scryfall’s database scryfall.com/docs/api/catalogs/powers

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.



100
101
102
# File 'lib/scryfall/catalog.rb', line 100

def powers(format: "json", pretty: false)
  request_catalogue("/catalog/powers", format, pretty)
end

.request_catalogue(path, format, pretty) ⇒ Object

Forms Request and calls connection. Used to DRY out the preceding catalog API.

Parameters:

  • format (String)

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

  • pretty (Boolean)

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



135
136
137
138
139
140
141
142
# File 'lib/scryfall/catalog.rb', line 135

def request_catalogue(path, format, pretty)
  req = Request.new(
      params = {format: format, pretty: pretty},
      headers = nil,
      body = nil)

  Scryfall::Catalog.new JSON.parse(connection.get(path, req).body)
end

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

Returns a Catalog of all spell types in Scryfall’s database scryfall.com/docs/api/catalogs/spell-types

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.



91
92
93
# File 'lib/scryfall/catalog.rb', line 91

def spell_types(format: "json", pretty: false)
  request_catalogue("/catalog/spell-types", format, pretty)
end

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

Returns a Catalog of all possible values for a creature or vehicle’s toughness in Scryfall’s database scryfall.com/docs/api/catalogs/toughnesses

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.



109
110
111
# File 'lib/scryfall/catalog.rb', line 109

def toughnesses(format: "json", pretty: false)
  request_catalogue("/catalog/toughnesses", format, pretty)
end

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

Returns a Catalog of all watermarks in Scryfall’s database scryfall.com/docs/api/catalogs/loyalties

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.



127
128
129
# File 'lib/scryfall/catalog.rb', line 127

def watermarks(format: "json", pretty: false)
  request_catalogue("/catalog/watermarks", format, pretty)
end

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

Returns a Catalog of all English words, of length 2 or more, that could appear in a card name. scryfall.com/docs/api/catalogs/word-bank

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.



37
38
39
# File 'lib/scryfall/catalog.rb', line 37

def word_bank(format: "json", pretty: false)
  request_catalogue("/catalog/word-bank", format, pretty)
end