Class: Voom::Presenters::DSL::Components::Table::Row::Column
- 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
-
#align ⇒ Object
Returns the value of attribute align.
-
#color ⇒ Object
Returns the value of attribute color.
-
#colspan ⇒ Object
Returns the value of attribute colspan.
-
#components ⇒ Object
Returns the value of attribute components.
Attributes inherited from EventBase
Attributes included from Mixins::Event
Attributes inherited from Base
#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type
Instance Method Summary collapse
-
#initialize(**attribs_, &block) ⇒ Column
constructor
A new instance of Column.
- #numeric?(_value = value&.text) ⇒ Boolean
- #value(*value, **attribs, &block) ⇒ Object
Methods included from Mixins::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
Methods included from Mixins::Icons
Methods included from Mixins::Selects
Methods included from Mixins::Chipset
Methods included from Mixins::Tooltips
Methods included from Mixins::Event
Methods inherited from Base
Methods included from Pluggable
#include_plugins, #plugin, #plugin_module
Methods included from Mixins::YieldTo
Methods included from Serializer
Methods included from Lockable
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 = [] end |
Instance Attribute Details
#align ⇒ Object
Returns the value of attribute align.
77 78 79 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 77 def align @align end |
#color ⇒ Object
Returns the value of attribute color.
77 78 79 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 77 def color @color end |
#colspan ⇒ Object
Returns the value of attribute colspan.
77 78 79 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 77 def colspan @colspan end |
#components ⇒ Object
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
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 |