Class: Parker::Screenshot

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

Overview

A class that models a single game screenshot.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Screenshot

Returns a new instance of Screenshot.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/parker/screenshot.rb', line 9

def initialize(path)
  @path = path

  name_pattern = /(\d{4})(\d{2})(\d{2})(\d+).+(\.[a-z]{3})/
  base_name = File.basename(@path)

  parts = base_name.match(name_pattern)

  @filename = if parts
                parts.to_a[1..-2].join('-') << parts[-1]
              else
                base_name
              end
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/parker/screenshot.rb', line 7

def filename
  @filename
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end