class Voom::Presenters::DSL::Components::Table::Row::Column
Constants
- VALID_ALIGNMENTS
Attributes
align[RW]
color[RW]
colspan[RW]
components[RW]
Public Class Methods
new(**attribs_, &block)
click to toggle source
Calls superclass method
Voom::Presenters::DSL::Components::EventBase::new
# File lib/voom/presenters/dsl/components/table.rb, line 79 def initialize(**attribs_, &block) super(type: :column, **attribs_, &block) value = attribs.delete(:value) @align = validate_alignment(attribs.delete(:align){numeric?(value) ? :right : :left}) self.value(value, **attribs.slice(:markdown)) if value @color = attribs.delete(:color) @colspan = attribs.delete(:colspan) @components = [] expand! end
Public Instance Methods
numeric?(_value = value&.text)
click to toggle source
# File lib/voom/presenters/dsl/components/table.rb, line 95 def numeric?(_value = value&.text) return true if _value.is_a? Numeric (_value.to_s.strip.sub(/\D/, '') =~ /^[\$]?[-+]?(,?[0-9])*\.?[0-9]+$/) != nil end
value(*value, **attribs, &block)
click to toggle source
# File lib/voom/presenters/dsl/components/table.rb, line 90 def value(*value, **attribs, &block) return @value if locked? @value = Components::Typography.new(parent: self, type: :text, text: value, **attribs, &block) end
Private Instance Methods
validate_alignment(value)
click to toggle source
# File lib/voom/presenters/dsl/components/table.rb, line 103 def validate_alignment(value) return :left if value.nil? unless VALID_ALIGNMENTS.include?(value.to_sym) raise Errors::ParameterValidation, "Invalid column alignment! Valid alignements include #{VALID_ALIGNMENTS.join(', ')}" end value end