Class: Caracal::Core::Models::ImageModel
- Defined in:
- lib/caracal/core/models/image_model.rb
Overview
This class handles block options passed to the img method.
Instance Attribute Summary collapse
-
#image_align ⇒ Object
readonly
Returns the value of attribute image_align.
-
#image_bottom ⇒ Object
readonly
Returns the value of attribute image_bottom.
-
#image_data ⇒ Object
readonly
Returns the value of attribute image_data.
-
#image_height ⇒ Object
readonly
Returns the value of attribute image_height.
-
#image_left ⇒ Object
readonly
Returns the value of attribute image_left.
-
#image_ppi ⇒ Object
readonly
Returns the value of attribute image_ppi.
-
#image_right ⇒ Object
readonly
Returns the value of attribute image_right.
-
#image_top ⇒ Object
readonly
Returns the value of attribute image_top.
-
#image_url ⇒ Object
readonly
accessors.
-
#image_width ⇒ Object
readonly
Returns the value of attribute image_width.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ ImageModel
constructor
initialization.
- #relationship_target ⇒ Object
-
#valid? ⇒ Boolean
VALIDATION ==============================.
Constructor Details
#initialize(options = {}, &block) ⇒ ImageModel
initialization
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/caracal/core/models/image_model.rb', line 40 def initialize(={}, &block) @image_ppi = DEFAULT_IMAGE_PPI @image_width = DEFAULT_IMAGE_WIDTH @image_height = DEFAULT_IMAGE_HEIGHT @image_align = DEFAULT_IMAGE_ALIGN @image_top = DEFAULT_IMAGE_TOP @image_bottom = DEFAULT_IMAGE_BOTTOM @image_left = DEFAULT_IMAGE_LEFT @image_right = DEFAULT_IMAGE_RIGHT super , &block end |
Instance Attribute Details
#image_align ⇒ Object (readonly)
Returns the value of attribute image_align.
32 33 34 |
# File 'lib/caracal/core/models/image_model.rb', line 32 def image_align @image_align end |
#image_bottom ⇒ Object (readonly)
Returns the value of attribute image_bottom.
34 35 36 |
# File 'lib/caracal/core/models/image_model.rb', line 34 def image_bottom @image_bottom end |
#image_data ⇒ Object (readonly)
Returns the value of attribute image_data.
28 29 30 |
# File 'lib/caracal/core/models/image_model.rb', line 28 def image_data @image_data end |
#image_height ⇒ Object (readonly)
Returns the value of attribute image_height.
31 32 33 |
# File 'lib/caracal/core/models/image_model.rb', line 31 def image_height @image_height end |
#image_left ⇒ Object (readonly)
Returns the value of attribute image_left.
35 36 37 |
# File 'lib/caracal/core/models/image_model.rb', line 35 def image_left @image_left end |
#image_ppi ⇒ Object (readonly)
Returns the value of attribute image_ppi.
29 30 31 |
# File 'lib/caracal/core/models/image_model.rb', line 29 def image_ppi @image_ppi end |
#image_right ⇒ Object (readonly)
Returns the value of attribute image_right.
36 37 38 |
# File 'lib/caracal/core/models/image_model.rb', line 36 def image_right @image_right end |
#image_top ⇒ Object (readonly)
Returns the value of attribute image_top.
33 34 35 |
# File 'lib/caracal/core/models/image_model.rb', line 33 def image_top @image_top end |
#image_url ⇒ Object (readonly)
accessors
27 28 29 |
# File 'lib/caracal/core/models/image_model.rb', line 27 def image_url @image_url end |
#image_width ⇒ Object (readonly)
Returns the value of attribute image_width.
30 31 32 |
# File 'lib/caracal/core/models/image_model.rb', line 30 def image_width @image_width end |
Instance Method Details
#relationship_target ⇒ Object
74 75 76 |
# File 'lib/caracal/core/models/image_model.rb', line 74 def relationship_target image_url || image_data end |
#valid? ⇒ Boolean
VALIDATION ==============================
105 106 107 108 |
# File 'lib/caracal/core/models/image_model.rb', line 105 def valid? dims = [:ppi, :width, :height, :top, :bottom, :left, :right].map { |m| send("image_#{ m }") } dims.all? { |d| d > 0 } end |