Class: Gamerom::Game
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Gamerom::Game
- Defined in:
- lib/gamerom/game.rb
Overview
Game - Represents a game ROM
Instance Method Summary collapse
- #filenames ⇒ Object
- #filepath ⇒ Object
- #install ⇒ Object
- #installed? ⇒ Boolean
- #state_filename ⇒ Object
- #to_s ⇒ Object
- #uninstall ⇒ Object
- #update_state(filenames) ⇒ Object
Instance Method Details
#filenames ⇒ Object
10 11 12 13 14 |
# File 'lib/gamerom/game.rb', line 10 def filenames YAML.load_file(state_filename).map do |filename| "#{filepath}/#{filename}" end end |
#filepath ⇒ Object
16 17 18 |
# File 'lib/gamerom/game.rb', line 16 def filepath "#{Gamerom::GAME_DIR}/#{repo.name}/#{platform}/#{region}" end |
#install ⇒ Object
20 21 22 23 24 |
# File 'lib/gamerom/game.rb', line 20 def install repo.install self do |filenames| update_state filenames end end |
#installed? ⇒ Boolean
26 27 28 |
# File 'lib/gamerom/game.rb', line 26 def installed? File.exist? state_filename end |
#state_filename ⇒ Object
30 31 32 |
# File 'lib/gamerom/game.rb', line 30 def state_filename "#{Gamerom::STATE_DIR}/#{repo.name}/#{platform}/#{region}/#{id}" end |
#to_s ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/gamerom/game.rb', line 34 def to_s install_status = '' install_status = " (#{shell.set_color "installed", :green})" if installed? = '' = " - tags: #{.join(", ")}" if respond_to?(:tags) && !.empty? "#{id} - #{name} - #{region}#{install_status}#{}" end |
#uninstall ⇒ Object
42 43 44 45 |
# File 'lib/gamerom/game.rb', line 42 def uninstall FileUtils.rm_rf filenames FileUtils.rm_rf state_filename end |