Class: UiBibz::Utils::BreakdownClassNameGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ui_bibz/utils/breakdown_class_name_generator.rb

Overview

Generate the col class name

Constant Summary collapse

POSITIONING =
%i[num offset push pull order].freeze
BREAKPOINTS =
UiBibz::Ui::Core::Component::BREAKPOINTS
PARAMETERS =
BREAKPOINTS + POSITIONING + [:position]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, klass_name = 'col') ⇒ BreakdownClassNameGenerator

Returns a new instance of BreakdownClassNameGenerator.



10
11
12
13
# File 'lib/ui_bibz/utils/breakdown_class_name_generator.rb', line 10

def initialize(options = {}, klass_name = 'col')
  @options = options.is_a?(Integer) ? { num: options } : options
  @klass_name = klass_name
end

Instance Method Details

#class_namesObject

Possible options 3 or md: 3 or md: { num: 3 }, xs: { num: 4 }



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ui_bibz/utils/breakdown_class_name_generator.rb', line 17

def class_names
  return @klass_name unless col_options?

  kl = []
  @options.each do |key, value|
    kl << write_classes(key.to_sym, value) if BREAKPOINTS.include?(key.to_sym)
  end
  kl << write_classes(nil, @options)

  kl.delete_if(&:blank?)
end