Class: Voom::Presenters::DSL::Components::Select
- Defined in:
- lib/voom/presenters/dsl/components/select.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Option
Instance Attribute Summary collapse
-
#full_width ⇒ Object
readonly
Returns the value of attribute full_width.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#outlined ⇒ Object
readonly
Returns the value of attribute outlined.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
Attributes inherited from Input
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
- #hint(hint = nil) ⇒ Object
- #icon(icon = nil, **attribs, &block) ⇒ Object
-
#initialize(**attribs_, &block) ⇒ Select
constructor
A new instance of Select.
- #label(text = nil) ⇒ Object
- #option(text = nil, **attribs, &block) ⇒ Object
- #value ⇒ Object
Methods inherited from Input
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) ⇒ Select
Returns a new instance of Select.
9 10 11 12 13 14 15 16 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 9 def initialize(**attribs_, &block) super(type: :select, **attribs_, &block) @required = attribs.delete(:required) @full_width = attribs.delete(:full_width){ true } @outlined = attribs.delete(:outlined){ true } @options = [] end |
Instance Attribute Details
#full_width ⇒ Object (readonly)
Returns the value of attribute full_width.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 7 def full_width @full_width end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 7 def @options end |
#outlined ⇒ Object (readonly)
Returns the value of attribute outlined.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 7 def outlined @outlined end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
7 8 9 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 7 def required @required end |
Instance Method Details
#hint(hint = nil) ⇒ Object
33 34 35 36 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 33 def hint(hint=nil) return @hint if locked? @hint = hint end |
#icon(icon = nil, **attribs, &block) ⇒ Object
38 39 40 41 42 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 38 def icon(icon=nil, **attribs, &block) return @icon if locked? @icon = Components::Icon.new(parent: self, icon: icon, position: attribs.delete(:position){:right}, **attribs, &block) end |
#label(text = nil) ⇒ Object
18 19 20 21 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 18 def label(text=nil) return @label if locked? @label = text end |
#option(text = nil, **attribs, &block) ⇒ Object
23 24 25 26 27 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 23 def option(text=nil, **attribs, &block) @options << Option.new(parent: self, text: text, **attribs, &block) end |
#value ⇒ Object
29 30 31 |
# File 'lib/voom/presenters/dsl/components/select.rb', line 29 def value @options.select(&:_selected?).first&.value end |