Class: Rubord::Components::Section
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Rubord::Components::Section
- Defined in:
- lib/rubord/components/containers/section.rb
Instance Attribute Summary
Attributes inherited from BaseComponent
Instance Method Summary collapse
-
#initialize(text:, accessory: nil) ⇒ Section
constructor
A new instance of Section.
- #to_h ⇒ Object
Constructor Details
#initialize(text:, accessory: nil) ⇒ Section
Returns a new instance of Section.
6 7 8 9 10 |
# File 'lib/rubord/components/containers/section.rb', line 6 def initialize(text:, accessory: nil) super(9) @text = text @accessory = accessory end |
Instance Method Details
#to_h ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rubord/components/containers/section.rb', line 12 def to_h h = { type: @type, text: @text.is_a?(String) ? { type: 10, content: @text } : @text.to_h } h[:accessory] = @accessory.to_h if @accessory h end |