Class: Voom::Presenters::DSL::Components::Table::Row::Column

Inherits:
EventBase
  • Object
show all
Includes:
Mixins::Chipset, Mixins::Content, Mixins::Icons, Mixins::Selects, Mixins::Tooltips, Mixins::Typography
Defined in:
lib/voom/presenters/dsl/components/table.rb

Instance Attribute Summary collapse

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods included from Mixins::Content

#content

Methods included from Mixins::Typography

#blank, #body, #body2, #caption, #headline, #headline1, #headline2, #headline3, #headline4, #headline5, #headline6, #link, #overline, #page_title, #separator, #subtitle, #subtitle2, #text, #title

Methods included from Mixins::Append

#<<, #yield_to

Methods included from Mixins::Icons

#icon

Methods included from Mixins::Selects

#multi_select, #select

Methods included from Mixins::Chipset

#chipset

Methods included from Mixins::Tooltips

#tooltip

Methods included from Mixins::Event

#event

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ Column

Returns a new instance of Column.



79
80
81
82
83
84
85
86
87
88
# 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

Instance Attribute Details

#alignObject

Returns the value of attribute align.



77
78
79
# File 'lib/voom/presenters/dsl/components/table.rb', line 77

def align
  @align
end

#colorObject

Returns the value of attribute color.



77
78
79
# File 'lib/voom/presenters/dsl/components/table.rb', line 77

def color
  @color
end

#colspanObject

Returns the value of attribute colspan.



77
78
79
# File 'lib/voom/presenters/dsl/components/table.rb', line 77

def colspan
  @colspan
end

#componentsObject

Returns the value of attribute components.



77
78
79
# File 'lib/voom/presenters/dsl/components/table.rb', line 77

def components
  @components
end

Instance Method Details

#numeric?(_value = value&.text) ⇒ Boolean

Returns:

  • (Boolean)


95
96
97
98
# 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) ⇒ Object



90
91
92
93
# 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