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



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/caracal/core/models/image_model.rb', line 40

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

Instance Attribute Details

#image_alignObject (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_bottomObject (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_dataObject (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_heightObject (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_leftObject (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_ppiObject (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_rightObject (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_topObject (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_urlObject (readonly)

accessors



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

def image_url
  @image_url
end

#image_widthObject (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_targetObject



74
75
76
# File 'lib/caracal/core/models/image_model.rb', line 74

def relationship_target
  image_url || image_data
end

#valid?Boolean

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

Returns:

  • (Boolean)


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