class Gamerom::Game

Game - Represents a game ROM

Public Instance Methods

filenames() click to toggle source
# File lib/gamerom/game.rb, line 10
def filenames
  YAML.load_file(state_filename).map do |filename|
    "#{filepath}/#{filename}"
  end
end
filepath() click to toggle source
# File lib/gamerom/game.rb, line 16
def filepath
  "#{Gamerom::GAME_DIR}/#{repo.name}/#{platform}/#{region}"
end
install() click to toggle source
# File lib/gamerom/game.rb, line 20
def install
  repo.install self do |filenames|
    update_state filenames
  end
end
installed?() click to toggle source
# File lib/gamerom/game.rb, line 26
def installed?
  File.exist? state_filename
end
state_filename() click to toggle source
# File lib/gamerom/game.rb, line 30
def state_filename
  "#{Gamerom::STATE_DIR}/#{repo.name}/#{platform}/#{region}/#{id}"
end
to_s() click to toggle source
# File lib/gamerom/game.rb, line 34
def to_s
  install_status = ''
  install_status = " (#{shell.set_color "installed", :green})" if installed?
  tags = ''
  tags = " - tags: #{tags.join(", ")}" if respond_to?(:tags) && !tags.empty?
  "#{id} - #{name} - #{region}#{install_status}#{tags}"
end
uninstall() click to toggle source
# File lib/gamerom/game.rb, line 42
def uninstall
  FileUtils.rm_rf filenames
  FileUtils.rm_rf state_filename
end
update_state(filenames) click to toggle source
# File lib/gamerom/game.rb, line 47
def update_state(filenames)
  FileUtils.mkdir_p("#{Gamerom::STATE_DIR}/#{repo.name}/#{platform}/#{region}")
  File.write(state_filename, filenames.to_yaml)
end

Private Instance Methods

shell() click to toggle source
# File lib/gamerom/game.rb, line 54
def shell
  @shell ||= Thor::Shell::Color.new
end