Class: Parker::Platform::PS4

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

Overview

A class that models the PlayStation 4 platform.

Constant Summary collapse

NAME_FILTER =
{
  '' => '',
  '_' => ' -'
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#games, #name, #source_path

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Parker::Platform::Base

Instance Method Details

#scan_gamesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/parker/platform/ps4.rb', line 14

def scan_games
  screenshots_path = File.join(source_path, '*', File::SEPARATOR, '*.jpg')

  Dir.glob(screenshots_path).each do |path|
    next if path.match?(/\_\d.jpg$/)

    game_name = File.dirname(path).split(File::SEPARATOR)[-1]
    game_name.gsub!(/[#{NAME_FILTER.keys.join}]/, NAME_FILTER)
    game_id = Digest::SHA1.hexdigest(game_name)[0..9]

    games[game_id] ||= Game.new(game_id, game_name)
    games[game_id].screenshots << Screenshot.new(path)
  end
end