class UiBibz::Utils::BreakdownClassNameGenerator
Generate the col class name
Constants
- BREAKPOINTS
- PARAMETERS
- POSITIONING
Public Class Methods
new(options = {}, klass_name = 'col')
click to toggle source
# 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
Public Instance Methods
class_names()
click to toggle source
Possible options 3 or md: 3 or md: { num: 3 }, xs: { num: 4 }
# 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
Private Instance Methods
col_options?()
click to toggle source
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 31 def col_options? (@options.keys.map(&:to_sym) & PARAMETERS).present? end
num(size, number, _pos = nil)
click to toggle source
col-md-9
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 49 def num(size, number, _pos = nil) size == :auto ? @klass_name : ["#{@klass_name}#{position}", size, number].compact.join('-') end
offset(size, number)
click to toggle source
col-md-offset-9
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 54 def offset(size, number) ['offset', size, number].compact.join('-') end
order(size, number)
click to toggle source
order-md-9
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 64 def order(size, number) ['order', size, number].compact.join('-') end
position()
click to toggle source
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 73 def position case @position || @options[:position] when :vertical 'y' when :horizontal 'x' end end
pull(size, number)
click to toggle source
col-md-pull-9
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 69 def pull(size, number) [@klass_name, size, 'pull', number].compact.join('-') end
push(size, number)
click to toggle source
col-md-push-9
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 59 def push(size, number) [@klass_name, size, 'push', number].compact.join('-') end
write_classes(size, opts)
click to toggle source
md: 8 or md: { num: 3}, xs: { num: 4 }
# File lib/ui_bibz/utils/breakdown_class_name_generator.rb, line 36 def write_classes(size, opts) if opts.is_a?(Hash) @position = opts[:position] opts.filter_map do |k, v| send(k, size, v) if POSITIONING.include?(k.to_sym) end.join(' ') else send('num', size, opts) end end