Class: Arara::RadioButtonComponent
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Arara::RadioButtonComponent
- Includes:
- BaseComponent
- Defined in:
- app/components/arara/radio_button_component.rb
Instance Attribute Summary collapse
-
#checked ⇒ Object
readonly
Returns the value of attribute checked.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #default_html_class ⇒ Object
- #html_input_options ⇒ Object
-
#initialize(id:, name:, value:, checked: false, type: "radio", **kw) ⇒ RadioButtonComponent
constructor
A new instance of RadioButtonComponent.
Methods included from BaseComponent
#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_options, #html_tag, included
Constructor Details
#initialize(id:, name:, value:, checked: false, type: "radio", **kw) ⇒ RadioButtonComponent
Returns a new instance of RadioButtonComponent.
7 8 9 10 11 12 13 14 15 |
# File 'app/components/arara/radio_button_component.rb', line 7 def initialize(id:, name:, value:, checked: false, type: "radio", **kw) @id = id @name = name @checked = checked @value = value @type = type super(tag: "div", **kw) end |
Instance Attribute Details
#checked ⇒ Object (readonly)
Returns the value of attribute checked.
5 6 7 |
# File 'app/components/arara/radio_button_component.rb', line 5 def checked @checked end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'app/components/arara/radio_button_component.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'app/components/arara/radio_button_component.rb', line 5 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'app/components/arara/radio_button_component.rb', line 5 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'app/components/arara/radio_button_component.rb', line 5 def value @value end |
Instance Method Details
#default_html_class ⇒ Object
31 32 33 |
# File 'app/components/arara/radio_button_component.rb', line 31 def default_html_class "mdc-radio" end |
#html_input_options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/arara/radio_button_component.rb', line 17 def opts = { class: "mdc-radio__native-control", type: type, id: id, name: name, value: value } opts[:checked] = "" if checked opts end |