Class: Parker::Platform::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/parker/platform/base.rb

Overview

A base class for all platforms.

Direct Known Subclasses

PS4, Steam, Switch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source_path, game_data) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/parker/platform/base.rb', line 10

def initialize(name, source_path, game_data)
  @name = name || self.class.name.split('::').last
  @source_path = File.expand_path(source_path)
  @games = {}

  game_data&.map do |game_identifier, game_name|
    @games[game_identifier] = Game.new(game_identifier, game_name)
  end

  scan_games if Dir.exist?(@source_path)
end

Instance Attribute Details

#gamesObject

Returns the value of attribute games.



8
9
10
# File 'lib/parker/platform/base.rb', line 8

def games
  @games
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/parker/platform/base.rb', line 7

def name
  @name
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



7
8
9
# File 'lib/parker/platform/base.rb', line 7

def source_path
  @source_path
end

Instance Method Details

#scan_gamesObject



22
23
24
# File 'lib/parker/platform/base.rb', line 22

def scan_games
  raise 'Must be implemented by a subclass'
end