Class: CardDB::Game

Inherits:
Resource show all
Defined in:
lib/carddb/collection.rb

Overview

Wrapper for Game objects

Instance Attribute Summary

Attributes inherited from Resource

#client, #data

Instance Method Summary collapse

Methods inherited from Resource

#[], #initialize, #key?, #to_h, #to_json

Constructor Details

This class inherits a constructor from CardDB::Resource

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


345
346
347
# File 'lib/carddb/collection.rb', line 345

def archived?
  data['isArchived']
end

#cover_urlObject



361
362
363
# File 'lib/carddb/collection.rb', line 361

def cover_url
  data.dig('coverFile', 'url')
end

#created_atObject



365
366
367
# File 'lib/carddb/collection.rb', line 365

def created_at
  parse_time(data['createdAt'])
end

#datasets(purpose: nil, search: nil, first: nil, after: nil) ⇒ Collection<Dataset>

Fetch datasets belonging to this game. Unfiltered results are cached after the first call.

Parameters:

  • purpose (String, nil) (defaults to: nil)

    Filter by dataset purpose (DATA or RULES)

  • search (String, nil) (defaults to: nil)

    Search by dataset name

  • first (Integer, nil) (defaults to: nil)

    Maximum number of results

  • after (String, nil) (defaults to: nil)

    Cursor for pagination

Returns:

Raises:



382
383
384
385
386
387
388
# File 'lib/carddb/collection.rb', line 382

def datasets(purpose: nil, search: nil, first: nil, after: nil)
  if purpose.nil? && search.nil? && first.nil? && after.nil?
    @datasets ||= fetch_datasets
  else
    fetch_datasets(purpose: purpose, search: search, first: first, after: after)
  end
end

#descriptionObject



333
334
335
# File 'lib/carddb/collection.rb', line 333

def description
  data['description']
end

#idObject



321
322
323
# File 'lib/carddb/collection.rb', line 321

def id
  data['id']
end

#keyObject



325
326
327
# File 'lib/carddb/collection.rb', line 325

def key
  data['key']
end

#logo_urlObject



357
358
359
# File 'lib/carddb/collection.rb', line 357

def logo_url
  data.dig('logoFile', 'url')
end

#nameObject



329
330
331
# File 'lib/carddb/collection.rb', line 329

def name
  data['name']
end

#publisherObject



353
354
355
# File 'lib/carddb/collection.rb', line 353

def publisher
  data['publisher']
end

#publisher_idObject



349
350
351
# File 'lib/carddb/collection.rb', line 349

def publisher_id
  data['publisherId']
end

#updated_atObject



369
370
371
# File 'lib/carddb/collection.rb', line 369

def updated_at
  parse_time(data['updatedAt'])
end

#visibilityObject



341
342
343
# File 'lib/carddb/collection.rb', line 341

def visibility
  data['visibility']
end

#websiteObject



337
338
339
# File 'lib/carddb/collection.rb', line 337

def website
  data['website']
end