Class: Parker::Game

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

Overview

A class that models a single game.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, name) ⇒ Game

Returns a new instance of Game.



8
9
10
11
12
# File 'lib/parker/game.rb', line 8

def initialize(identifier, name)
  @identifier = identifier
  @name = name
  @screenshots = []
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



6
7
8
# File 'lib/parker/game.rb', line 6

def identifier
  @identifier
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/parker/game.rb', line 6

def name
  @name
end

#screenshotsObject

Returns the value of attribute screenshots.



6
7
8
# File 'lib/parker/game.rb', line 6

def screenshots
  @screenshots
end

Instance Method Details

#copy_screenshots(output_path) ⇒ Object



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

def copy_screenshots(output_path)
  copied_screenshots = 0

  screenshots.each do |screenshot|
    platform_path = File.join(output_path, name)
    new_file_path = File.join(platform_path, screenshot.filename)

    next if File.exist?(new_file_path)

    FileUtils.mkdir_p(platform_path) unless Dir.exist?(platform_path)
    FileUtils.cp(screenshot.path, new_file_path)

    copied_screenshots += 1
  end

  copied_screenshots
end