Class: AppscreensIoUploader::Screenshot
- Inherits:
-
Object
- Object
- AppscreensIoUploader::Screenshot
- Defined in:
- lib/appscreensIoUploader/screenshot.rb
Overview
Represents one screenshot
Instance Attribute Summary collapse
-
#path ⇒ Object
path to the screenshot.
-
#screen_size ⇒ Object
deliver screen size type, is unique per device type, used in device_name.
-
#size ⇒ Object
size in px array of 2 elements: height and width.
Instance Method Summary collapse
-
#initialize(path) ⇒ Screenshot
constructor
path: Path to screenshot color: Color to use for the frame.
- #is_portrait? ⇒ Boolean
- #is_supported_screen_size? ⇒ Boolean
-
#orientation_name ⇒ Object
The name of the orientation of a screenshot.
- #to_s ⇒ Object
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
#path ⇒ Object
path to the screenshot
4 5 6 |
# File 'lib/appscreensIoUploader/screenshot.rb', line 4 def path @path end |
#screen_size ⇒ Object
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 |
#size ⇒ Object
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
42 43 44 |
# File 'lib/appscreensIoUploader/screenshot.rb', line 42 def is_portrait? return (orientation_name == Orientation::PORTRAIT) end |
#is_supported_screen_size? ⇒ 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_name ⇒ Object
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_s ⇒ Object
46 47 48 |
# File 'lib/appscreensIoUploader/screenshot.rb', line 46 def to_s self.path end |