Class: Alchemy::ImageCropperSettings
- Inherits:
-
Object
- Object
- Alchemy::ImageCropperSettings
- Defined in:
- app/models/alchemy/image_cropper_settings.rb
Overview
Settings for the graphical JS image cropper
Instance Attribute Summary collapse
-
#default_crop_from ⇒ Object
readonly
Returns the value of attribute default_crop_from.
-
#default_crop_size ⇒ Object
readonly
Returns the value of attribute default_crop_size.
-
#fixed_ratio ⇒ Object
readonly
Returns the value of attribute fixed_ratio.
-
#image_height ⇒ Object
readonly
Returns the value of attribute image_height.
-
#image_width ⇒ Object
readonly
Returns the value of attribute image_width.
-
#render_size ⇒ Object
readonly
Returns the value of attribute render_size.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(render_size:, default_crop_from:, default_crop_size:, fixed_ratio:, image_width:, image_height:) ⇒ ImageCropperSettings
constructor
A new instance of ImageCropperSettings.
- #to_h ⇒ Object
Constructor Details
#initialize(render_size:, default_crop_from:, default_crop_size:, fixed_ratio:, image_width:, image_height:) ⇒ ImageCropperSettings
Returns a new instance of ImageCropperSettings.
8 9 10 11 12 13 14 15 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 8 def initialize(render_size:, default_crop_from:, default_crop_size:, fixed_ratio:, image_width:, image_height:) @render_size = render_size || [0, 0] @fixed_ratio = fixed_ratio @image_width = image_width.to_i @image_height = image_height.to_i @default_crop_from = default_crop_from || [0, 0] @default_crop_size = default_crop_size || [@image_width, @image_height] end |
Instance Attribute Details
#default_crop_from ⇒ Object (readonly)
Returns the value of attribute default_crop_from.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def default_crop_from @default_crop_from end |
#default_crop_size ⇒ Object (readonly)
Returns the value of attribute default_crop_size.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def default_crop_size @default_crop_size end |
#fixed_ratio ⇒ Object (readonly)
Returns the value of attribute fixed_ratio.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def fixed_ratio @fixed_ratio end |
#image_height ⇒ Object (readonly)
Returns the value of attribute image_height.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def image_height @image_height end |
#image_width ⇒ Object (readonly)
Returns the value of attribute image_width.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def image_width @image_width end |
#render_size ⇒ Object (readonly)
Returns the value of attribute render_size.
6 7 8 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 6 def render_size @render_size end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 27 def [](key) to_h[key] end |
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/models/alchemy/image_cropper_settings.rb', line 17 def to_h return {} if image_width.zero? || image_height.zero? { min_size: large_enough? ? min_size : false, ratio: ratio, default_box: default_box }.freeze end |