Class: ElementComponent::Components::CardImage

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/card/image.rb

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(src: "", top: false, bottom: false, **attributes, &block) ⇒ CardImage

Returns a new instance of CardImage.



6
7
8
9
10
11
12
13
14
# File 'lib/element_component/components/card/image.rb', line 6

def initialize(src: "", top: false, bottom: false, **attributes, &block)
  super("img", closing_tag: false, &block)

  add_attribute(class: "card-img")
  add_attribute(class: "card-img-top") if top
  add_attribute(class: "card-img-bottom") if bottom
  add_attribute(src: src)
  add_attribute(attributes) unless attributes.empty?
end