Class: RomLoader::GameSystem
- Inherits:
-
Object
- Object
- RomLoader::GameSystem
- Defined in:
- lib/romloader/game_system.rb
Overview
The class whose instances represent an individual game system (e.g. Sega Genesis object)
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#rom_index_url ⇒ Object
Returns the value of attribute rom_index_url.
-
#rom_indices ⇒ Object
writeonly
Sets the attribute rom_indices.
Class Method Summary collapse
-
.all ⇒ Object
Retrieves an array of all GameSystem objects.
-
.create_from_collection(system_array) ⇒ Object
Creates multiple GameSystem objects from information scraped from freeroms.com.
Instance Method Summary collapse
-
#add_roms_to_collection_by_letter(letter_index, game_obj_array) ⇒ Object
Add the game collection scraped from freeroms.com to the GameSystem object to the roms Hash.
-
#get_rom_collection_url(letter_index) ⇒ Object
Retrieves the url for roms of a particular letter index (e.g. “A” => “freeroms.com/genesis_games_that_start_with_a.html”).
-
#get_rom_indices ⇒ Object
Retrieves an array of the indicies for the roms (i.e. [“A”,“B”,“C”…]).
-
#get_roms_by_letter(letter_index) ⇒ Object
Retrieves an array of all GameRom objects starting which the provided letter index (e.g. [Sonic the Hedgehog, Streets of Rage,…]).
-
#initialize(name:, rom_index_url:) ⇒ GameSystem
constructor
Create individual game system objects from information scraped from freeroms.com, sets all instance variables.
Constructor Details
#initialize(name:, rom_index_url:) ⇒ GameSystem
Create individual game system objects from information scraped from freeroms.com, sets all instance variables
12 13 14 15 16 17 18 |
# File 'lib/romloader/game_system.rb', line 12 def initialize(name:, rom_index_url:) @name = name @rom_index_url = rom_index_url @rom_indices = {} @roms = {} @@all << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/romloader/game_system.rb', line 6 def name @name end |
#rom_index_url ⇒ Object
Returns the value of attribute rom_index_url.
6 7 8 |
# File 'lib/romloader/game_system.rb', line 6 def rom_index_url @rom_index_url end |
#rom_indices=(value) ⇒ Object (writeonly)
Sets the attribute rom_indices
7 8 9 |
# File 'lib/romloader/game_system.rb', line 7 def rom_indices=(value) @rom_indices = value end |
Class Method Details
.all ⇒ Object
Retrieves an array of all GameSystem objects
27 28 29 |
# File 'lib/romloader/game_system.rb', line 27 def self.all @@all end |
.create_from_collection(system_array) ⇒ Object
Creates multiple GameSystem objects from information scraped from freeroms.com
21 22 23 24 |
# File 'lib/romloader/game_system.rb', line 21 def self.create_from_collection(system_array) system_array.each { |system_details| self.new(system_details)} nil end |
Instance Method Details
#add_roms_to_collection_by_letter(letter_index, game_obj_array) ⇒ Object
Add the game collection scraped from freeroms.com to the GameSystem object to the roms Hash
50 51 52 53 54 |
# File 'lib/romloader/game_system.rb', line 50 def add_roms_to_collection_by_letter(letter_index, game_obj_array) game_obj_array.each { |game| game.system = self } @roms[letter_index] = game_obj_array end |
#get_rom_collection_url(letter_index) ⇒ Object
Retrieves the url for roms of a particular letter index (e.g. “A” => “freeroms.com/genesis_games_that_start_with_a.html”)
45 46 47 |
# File 'lib/romloader/game_system.rb', line 45 def get_rom_collection_url(letter_index) @rom_indices[letter_index] end |
#get_rom_indices ⇒ Object
Retrieves an array of the indicies for the roms (i.e. [“A”,“B”,“C”…])
39 40 41 |
# File 'lib/romloader/game_system.rb', line 39 def get_rom_indices @rom_indices.keys end |
#get_roms_by_letter(letter_index) ⇒ Object
Retrieves an array of all GameRom objects starting which the provided letter index (e.g. [Sonic the Hedgehog, Streets of Rage,…])
33 34 35 |
# File 'lib/romloader/game_system.rb', line 33 def get_roms_by_letter(letter_index) @roms[letter_index] end |