Class: UiBibz::Builders::DataHtmlOptionsBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper
Defined in:
lib/ui_bibz/builders/data_html_options_builder.rb

Overview

Class to build html classes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, options, html_options) ⇒ DataHtmlOptionsBuilder

Returns a new instance of DataHtmlOptionsBuilder.



10
11
12
13
14
15
16
17
18
19
# File 'lib/ui_bibz/builders/data_html_options_builder.rb', line 10

def initialize(content, options, html_options)
  @content = content
  @options = options
  @html_options = html_options

  stimulus_data_html
  hotwire_data_html
  tooltip_data_html
  popover_data_html
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/ui_bibz/builders/data_html_options_builder.rb', line 8

def content
  @content
end

#html_optionsObject Also known as: output

Returns the value of attribute html_options.



7
8
9
# File 'lib/ui_bibz/builders/data_html_options_builder.rb', line 7

def html_options
  @html_options
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/ui_bibz/builders/data_html_options_builder.rb', line 8

def options
  @options
end

Instance Method Details

#add(name, value: true) ⇒ Object

Add html data arguments



22
23
24
25
26
27
28
# File 'lib/ui_bibz/builders/data_html_options_builder.rb', line 22

def add(name, value: true)
  return if value.blank? && value != false

  html_options[:data] = {} if html_options[:data].nil?
  value = value.strip if value.is_a?(String)
  html_options[:data].update({ name => value })
end