Class: Frameit::Editor
- Inherits:
-
Object
- Object
- Frameit::Editor
- Defined in:
- frameit/lib/frameit/editor.rb
Overview
Currently the class is 2 lines too long. Reevaluate refactoring when it’s length changes significantly
Direct Known Subclasses
Instance Attribute Summary collapse
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#frame ⇒ Object
the frame of the device.
-
#frame_path ⇒ Object
Returns the value of attribute frame_path.
-
#image ⇒ Object
the current image used for editing.
-
#screenshot ⇒ Object
rubocop:disable Metrics/ClassLength.
-
#space_to_device ⇒ Object
Returns the value of attribute space_to_device.
Instance Method Summary collapse
- #frame! ⇒ Object
-
#initialize(screenshot, debug_mode = false) ⇒ Editor
constructor
A new instance of Editor.
- #load_frame ⇒ Object
- #prepare_image ⇒ Object
- #rotation_for_device_orientation ⇒ Object
- #should_skip? ⇒ Boolean
Constructor Details
#initialize(screenshot, debug_mode = false) ⇒ Editor
Returns a new instance of Editor.
21 22 23 24 |
# File 'frameit/lib/frameit/editor.rb', line 21 def initialize(screenshot, debug_mode = false) @screenshot = screenshot self.debug_mode = debug_mode end |
Instance Attribute Details
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
15 16 17 |
# File 'frameit/lib/frameit/editor.rb', line 15 def debug_mode @debug_mode end |
#frame ⇒ Object
the frame of the device
17 18 19 |
# File 'frameit/lib/frameit/editor.rb', line 17 def frame @frame end |
#frame_path ⇒ Object
Returns the value of attribute frame_path.
16 17 18 |
# File 'frameit/lib/frameit/editor.rb', line 16 def frame_path @frame_path end |
#image ⇒ Object
the current image used for editing
18 19 20 |
# File 'frameit/lib/frameit/editor.rb', line 18 def image @image end |
#screenshot ⇒ Object
rubocop:disable Metrics/ClassLength
14 15 16 |
# File 'frameit/lib/frameit/editor.rb', line 14 def screenshot @screenshot end |
#space_to_device ⇒ Object
Returns the value of attribute space_to_device.
19 20 21 |
# File 'frameit/lib/frameit/editor.rb', line 19 def space_to_device @space_to_device end |
Instance Method Details
#frame! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'frameit/lib/frameit/editor.rb', line 26 def frame! prepare_image @frame_path = load_frame if @frame_path # Mac doesn't need a frame self.frame = MiniMagick::Image.open(@frame_path) # Rotate the frame according to the device orientation self.frame.rotate(self.rotation_for_device_orientation) elsif self.class == Editor # Couldn't find device frame (probably an iPhone 4, for which there are no images available any more) # Message is already shown elsewhere return end if is_complex_framing_mode? @image = complex_framing else # easy mode from 1.0 - no title or background put_into_frame # put it in the frame end store_result # write to file system end |
#load_frame ⇒ Object
50 51 52 53 54 55 56 |
# File 'frameit/lib/frameit/editor.rb', line 50 def load_frame color = fetch_frame_color if color screenshot.color = color end TemplateFinder.get_template(screenshot) end |
#prepare_image ⇒ Object
58 59 60 |
# File 'frameit/lib/frameit/editor.rb', line 58 def prepare_image @image = MiniMagick::Image.open(screenshot.path) end |
#rotation_for_device_orientation ⇒ Object
62 63 64 65 66 |
# File 'frameit/lib/frameit/editor.rb', line 62 def rotation_for_device_orientation return 90 if self.screenshot.landscape_right? return -90 if self.screenshot.landscape_left? return 0 end |
#should_skip? ⇒ Boolean
68 69 70 |
# File 'frameit/lib/frameit/editor.rb', line 68 def should_skip? return is_complex_framing_mode? && !fetch_text(:title) end |