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
-
#frame ⇒ Object
the frame of the device.
-
#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!(screenshot) ⇒ Object
- #load_frame ⇒ Object
- #prepare_image ⇒ Object
- #rotation_for_device_orientation ⇒ Object
Instance Attribute Details
#frame ⇒ Object
the frame of the device
15 16 17 |
# File 'frameit/lib/frameit/editor.rb', line 15 def frame @frame end |
#image ⇒ Object
the current image used for editing
16 17 18 |
# File 'frameit/lib/frameit/editor.rb', line 16 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.
17 18 19 |
# File 'frameit/lib/frameit/editor.rb', line 17 def space_to_device @space_to_device end |
Instance Method Details
#frame!(screenshot) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'frameit/lib/frameit/editor.rb', line 19 def frame!(screenshot) self.screenshot = screenshot prepare_image frame = load_frame if frame # Mac doesn't need a frame self.frame = MiniMagick::Image.open(frame) # 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 should_add_title? @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
44 45 46 47 48 49 50 |
# File 'frameit/lib/frameit/editor.rb', line 44 def load_frame color = fetch_frame_color if color screenshot.color = color end TemplateFinder.get_template(screenshot) end |
#prepare_image ⇒ Object
52 53 54 |
# File 'frameit/lib/frameit/editor.rb', line 52 def prepare_image @image = MiniMagick::Image.open(screenshot.path) end |
#rotation_for_device_orientation ⇒ Object
56 57 58 59 60 |
# File 'frameit/lib/frameit/editor.rb', line 56 def rotation_for_device_orientation return 90 if self.screenshot.landscape_right? return -90 if self.screenshot.landscape_left? return 0 end |