Class: Maglev::Uikit::ImageLibrary::CardComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Maglev::Uikit::ImageLibrary::CardComponent
- Defined in:
- app/components/maglev/uikit/image_library/card_component.rb
Instance Attribute Summary collapse
-
#byte_size ⇒ Object
readonly
Returns the value of attribute byte_size.
-
#delete_path ⇒ Object
readonly
Returns the value of attribute delete_path.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#picker_attributes ⇒ Object
readonly
Returns the value of attribute picker_attributes.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(image:, delete_path:, picker_attributes: nil) ⇒ CardComponent
constructor
A new instance of CardComponent.
- #picker_event_image_payload ⇒ Object
- #picker_event_name ⇒ Object
- #picker_event_payload ⇒ Object
- #picker_mode? ⇒ Boolean
- #width_and_height? ⇒ Boolean
Methods inherited from BaseComponent
Constructor Details
#initialize(image:, delete_path:, picker_attributes: nil) ⇒ CardComponent
Returns a new instance of CardComponent.
9 10 11 12 13 14 15 16 17 18 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 9 def initialize(image:, delete_path:, picker_attributes: nil) @id = image[:id] @image_url = image[:image_url] @filename = image[:filename] @width = image[:width] @height = image[:height] @byte_size = image[:byte_size] @delete_path = delete_path @picker_attributes = picker_attributes end |
Instance Attribute Details
#byte_size ⇒ Object (readonly)
Returns the value of attribute byte_size.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def byte_size @byte_size end |
#delete_path ⇒ Object (readonly)
Returns the value of attribute delete_path.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def delete_path @delete_path end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def filename @filename end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def id @id end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def image_url @image_url end |
#picker_attributes ⇒ Object (readonly)
Returns the value of attribute picker_attributes.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def picker_attributes @picker_attributes end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 7 def width @width end |
Instance Method Details
#picker_event_image_payload ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 31 def picker_event_image_payload { id: id, filename: filename, url: image_url, width: width, height: height, byte_size: byte_size } end |
#picker_event_name ⇒ Object
42 43 44 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 42 def picker_event_name "image-selected-#{picker_attributes[:source]}" end |
#picker_event_payload ⇒ Object
24 25 26 27 28 29 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 24 def picker_event_payload { source: picker_attributes[:source], image: picker_event_image_payload }.to_json end |
#picker_mode? ⇒ Boolean
20 21 22 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 20 def picker_mode? picker_attributes.present? && picker_attributes[:picker].present? end |
#width_and_height? ⇒ Boolean
46 47 48 |
# File 'app/components/maglev/uikit/image_library/card_component.rb', line 46 def width_and_height? width.present? && height.present? end |