Class: Rubord::Components::Section

Inherits:
BaseComponent show all
Defined in:
lib/rubord/components/containers/section.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#type

Instance Method Summary collapse

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_hObject



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