Class: JCropper::CroppedImage
- Inherits:
-
Object
- Object
- JCropper::CroppedImage
- Defined in:
- lib/jcropper/cropped_image.rb
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#attachment_name ⇒ Object
readonly
Returns the value of attribute attachment_name.
-
#coord_names ⇒ Object
readonly
Returns the value of attribute coord_names.
-
#cropped_geometry ⇒ Object
readonly
Returns the value of attribute cropped_geometry.
-
#original_geometry ⇒ Object
readonly
CRZ these two might get out of date…
-
#starting_crop ⇒ Object
readonly
Returns the value of attribute starting_crop.
-
#style_name ⇒ Object
readonly
Returns the value of attribute style_name.
Instance Method Summary collapse
-
#initialize(object) ⇒ CroppedImage
constructor
A new instance of CroppedImage.
- #max_crop ⇒ Object
- #target_geometry ⇒ Object
Constructor Details
#initialize(object) ⇒ CroppedImage
Returns a new instance of CroppedImage.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jcropper/cropped_image.rb', line 5 def initialize(object) @object = object @attachment_name = object.class.jcropper_defs[:attachment] @style_name = object.jcropper_defs[:style] @attachment = object.send() @coord_names = {} %w(x y w h).each{|v| @coord_names[v.to_sym] = JCropper.jattr(, style_name, v)} @starting_crop = @coord_names.inject({}) {|h,pair| h.merge({ pair[0] => object.send("#{pair[1].to_s}_was") }) } end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def @attachment end |
#attachment_name ⇒ Object (readonly)
Returns the value of attribute attachment_name.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def @attachment_name end |
#coord_names ⇒ Object (readonly)
Returns the value of attribute coord_names.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def coord_names @coord_names end |
#cropped_geometry ⇒ Object (readonly)
Returns the value of attribute cropped_geometry.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def cropped_geometry @cropped_geometry end |
#original_geometry ⇒ Object (readonly)
CRZ these two might get out of date…
17 18 19 |
# File 'lib/jcropper/cropped_image.rb', line 17 def original_geometry @original_geometry end |
#starting_crop ⇒ Object (readonly)
Returns the value of attribute starting_crop.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def starting_crop @starting_crop end |
#style_name ⇒ Object (readonly)
Returns the value of attribute style_name.
3 4 5 |
# File 'lib/jcropper/cropped_image.rb', line 3 def style_name @style_name end |
Instance Method Details
#max_crop ⇒ Object
29 30 31 |
# File 'lib/jcropper/cropped_image.rb', line 29 def max_crop [0, 0, original_geometry.width, original_geometry.height] end |
#target_geometry ⇒ Object
25 26 27 |
# File 'lib/jcropper/cropped_image.rb', line 25 def target_geometry @target_geometry ||= Paperclip::Geometry.parse(@object.send().styles[style_name.to_sym][:geometry]) end |