class Frameit::Screenshot
Represents one screenshot
Attributes
color[RW]
path[RW]
screen_size[RW]
size[RW]
Public Class Methods
new(path, color)
click to toggle source
path: Path to screenshot color: Color
to use for the frame
# File lib/frameit/screenshot.rb, line 11 def initialize(path, color) UI.user_error "Couldn't find file at path '#{path}'" unless File.exist? path @color = color @path = path @size = FastImage.size(path) @screen_size = ENV["FRAMEIT_FORCE_DEVICE_TYPE"] || Deliver::AppScreenshot.calculate_screen_size(path) end
Public Instance Methods
device_name()
click to toggle source
Device name for a given screen size. Used to use the correct template
# File lib/frameit/screenshot.rb, line 21 def device_name sizes = Deliver::AppScreenshot::ScreenSize case @screen_size when sizes::IOS_55 return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s Plus' : 'iPhone 7 Plus' when sizes::IOS_47 return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s' : 'iPhone 7' when sizes::IOS_40 return Frameit.config[:use_legacy_iphone5s] ? 'iPhone 5s' : 'iPhone SE' when sizes::IOS_35 return 'iPhone 4' when sizes::IOS_IPAD return 'iPad Air 2' when sizes::IOS_IPAD_PRO return 'iPad Pro' when sizes::MAC return 'MacBook' else UI.error "Unknown device type for size #{@screen_size} for path '#{path}'" end end
frame!()
click to toggle source
Add the device frame, this will also call the method that adds the background + title
# File lib/frameit/screenshot.rb, line 81 def frame! if self.mac? MacEditor.new.frame!(self) else Editor.new.frame!(self) end end
mac?()
click to toggle source
# File lib/frameit/screenshot.rb, line 62 def mac? return device_name == 'Mac' end
mini?()
click to toggle source
Super old devices (iPhone 4)
# File lib/frameit/screenshot.rb, line 58 def mini? (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35) end
orientation_name()
click to toggle source
The name of the orientation of a screenshot. Used to find the correct template
# File lib/frameit/screenshot.rb, line 67 def orientation_name return Orientation::PORTRAIT if size[0] < size[1] return Orientation::LANDSCAPE end
portrait?()
click to toggle source
# File lib/frameit/screenshot.rb, line 72 def portrait? return (orientation_name == Orientation::PORTRAIT) end
to_s()
click to toggle source
# File lib/frameit/screenshot.rb, line 76 def to_s self.path end
triple_density?()
click to toggle source
Is the device a 3x device? (e.g. 6 Plus)
# File lib/frameit/screenshot.rb, line 53 def triple_density? (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_55) end