Class: Caracal::Core::Models::ImageModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/caracal/core/models/image_model.rb

Overview

This class handles block options passed to the img method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ ImageModel

initialization



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/caracal/core/models/image_model.rb', line 37

def initialize(options={}, &block)
  @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 options, &block
end

Instance Attribute Details

#image_alignObject (readonly)

Returns the value of attribute image_align.



29
30
31
# File 'lib/caracal/core/models/image_model.rb', line 29

def image_align
  @image_align
end

#image_bottomObject (readonly)

Returns the value of attribute image_bottom.



31
32
33
# File 'lib/caracal/core/models/image_model.rb', line 31

def image_bottom
  @image_bottom
end

#image_heightObject (readonly)

Returns the value of attribute image_height.



28
29
30
# File 'lib/caracal/core/models/image_model.rb', line 28

def image_height
  @image_height
end

#image_leftObject (readonly)

Returns the value of attribute image_left.



32
33
34
# File 'lib/caracal/core/models/image_model.rb', line 32

def image_left
  @image_left
end

#image_rightObject (readonly)

Returns the value of attribute image_right.



33
34
35
# File 'lib/caracal/core/models/image_model.rb', line 33

def image_right
  @image_right
end

#image_topObject (readonly)

Returns the value of attribute image_top.



30
31
32
# File 'lib/caracal/core/models/image_model.rb', line 30

def image_top
  @image_top
end

#image_urlObject (readonly)

accessors



26
27
28
# File 'lib/caracal/core/models/image_model.rb', line 26

def image_url
  @image_url
end

#image_widthObject (readonly)

Returns the value of attribute image_width.



27
28
29
# File 'lib/caracal/core/models/image_model.rb', line 27

def image_width
  @image_width
end

Instance Method Details

#valid?Boolean

VALIDATION ==============================


90
91
92
93
# File 'lib/caracal/core/models/image_model.rb', line 90

def valid?
  dims = [:width, :height, :top, :bottom, :left, :right].map { |m| send("image_#{ m }") }
  dims.all? { |d| d > 0 }
end