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)


355
356
357
# File 'lib/carddb/collection.rb', line 355

def archived?
  data['isArchived']
end

#cover_urlObject



371
372
373
# File 'lib/carddb/collection.rb', line 371

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

#created_atObject



375
376
377
# File 'lib/carddb/collection.rb', line 375

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:



392
393
394
395
396
397
398
# File 'lib/carddb/collection.rb', line 392

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



343
344
345
# File 'lib/carddb/collection.rb', line 343

def description
  data['description']
end

#idObject



331
332
333
# File 'lib/carddb/collection.rb', line 331

def id
  data['id']
end

#keyObject



335
336
337
# File 'lib/carddb/collection.rb', line 335

def key
  data['key']
end

#logo_urlObject



367
368
369
# File 'lib/carddb/collection.rb', line 367

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

#nameObject



339
340
341
# File 'lib/carddb/collection.rb', line 339

def name
  data['name']
end

#publisherObject



363
364
365
# File 'lib/carddb/collection.rb', line 363

def publisher
  data['publisher']
end

#publisher_idObject



359
360
361
# File 'lib/carddb/collection.rb', line 359

def publisher_id
  data['publisherId']
end

#updated_atObject



379
380
381
# File 'lib/carddb/collection.rb', line 379

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

#visibilityObject



351
352
353
# File 'lib/carddb/collection.rb', line 351

def visibility
  data['visibility']
end

#websiteObject



347
348
349
# File 'lib/carddb/collection.rb', line 347

def website
  data['website']
end