Class: AppscreensIoUploader::Screenshot

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

Overview

Represents one screenshot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Screenshot

path: Path to screenshot color: Color to use for the frame



10
11
12
13
14
15
16
# File 'lib/appscreensIoUploader/screenshot.rb', line 10

def initialize(path)
  raise "Couldn't find file at path '#{path}'".red unless File.exists?path
  @path = path
  @size = FastImage.size(path)

  @screen_size = Deliver::AppScreenshot.calculate_screen_size(path)
end

Instance Attribute Details

#pathObject

path to the screenshot



4
5
6
# File 'lib/appscreensIoUploader/screenshot.rb', line 4

def path
  @path
end

#screen_sizeObject

deliver screen size type, is unique per device type, used in device_name



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

def screen_size
  @screen_size
end

#sizeObject

size in px array of 2 elements: height and width



5
6
7
# File 'lib/appscreensIoUploader/screenshot.rb', line 5

def size
  @size
end

Instance Method Details

#is_portrait?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/appscreensIoUploader/screenshot.rb', line 42

def is_portrait?
  return (orientation_name == Orientation::PORTRAIT)
end

#is_supported_screen_size?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appscreensIoUploader/screenshot.rb', line 18

def is_supported_screen_size?
  sizes = Deliver::AppScreenshot::ScreenSize
  case @screen_size
    when sizes::IOS_55
      return true
    when sizes::IOS_47
      return true
    when sizes::IOS_40
      return true
    when sizes::IOS_35
      return false
    when sizes::IOS_IPAD
      return false
    when sizes::MAC
      return false
  end
end

#orientation_nameObject

The name of the orientation of a screenshot. Used to find the correct template



37
38
39
40
# File 'lib/appscreensIoUploader/screenshot.rb', line 37

def orientation_name
  return Orientation::PORTRAIT if size[0] < size[1]
  return Orientation::LANDSCAPE
end

#to_sObject



46
47
48
# File 'lib/appscreensIoUploader/screenshot.rb', line 46

def to_s
  self.path
end