Class: Voom::Presenters::DSL::Components::Image

Inherits:
EventBase show all
Includes:
Mixins::Tooltips
Defined in:
lib/voom/presenters/dsl/components/image.rb

Constant Summary collapse

VALID_FIT_TYPES =
%i[contain cover fill fit].freeze
DEFAULT_POSITION =
:center

Instance Attribute Summary collapse

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods included from Mixins::Tooltips

#tooltip

Methods included from Mixins::Event

#event

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ Image

Returns a new instance of Image.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/voom/presenters/dsl/components/image.rb', line 26

def initialize(**attribs_, &block)
  super(type: :image, **attribs_, &block)

  @image = attribs.delete(:image)
  @description = attribs.delete(:description)

  @min_width = validate_size(attribs.delete(:min_width))
  @width = validate_size(attribs.delete(:width))
  @max_width = validate_size(attribs.delete(:max_width))

  @min_height = validate_size(attribs.delete(:min_height))
  @height = validate_size(attribs.delete(:height))
  @max_height = validate_size(attribs.delete(:max_height))

  @border = attribs.delete(:border)
  @border_color = attribs.delete(:border_color) { :primary }
  @border_radius = attribs.delete(:border_radius)

  @fit = validate_fit(attribs.delete(:fit) { :contain })
  @position = Array(attribs.delete(:position) { DEFAULT_POSITION }).compact

  @url = build_url

  expand!
end

Instance Attribute Details

#borderObject

Returns the value of attribute border.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def border
  @border
end

#border_colorObject

Returns the value of attribute border_color.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def border_color
  @border_color
end

#border_radiusObject

Returns the value of attribute border_radius.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def border_radius
  @border_radius
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def description
  @description
end

#fitObject

Returns the value of attribute fit.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def fit
  @fit
end

#heightObject

Returns the value of attribute height.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def height
  @height
end

#imageObject

Returns the value of attribute image.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def image
  @image
end

#max_heightObject

Returns the value of attribute max_height.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def max_height
  @max_height
end

#max_widthObject

Returns the value of attribute max_width.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def max_width
  @max_width
end

#min_heightObject

Returns the value of attribute min_height.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def min_height
  @min_height
end

#min_widthObject

Returns the value of attribute min_width.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def min_width
  @min_width
end

#positionObject

Returns the value of attribute position.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def position
  @position
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def url
  @url
end

#widthObject

Returns the value of attribute width.



11
12
13
# File 'lib/voom/presenters/dsl/components/image.rb', line 11

def width
  @width
end