Class: GovukComponent::TableComponent::CaptionComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/table_component/caption_component.rb

Constant Summary collapse

SIZES =
%w(s m l xl).freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(text: nil, id: nil, size: 'm', classes: [], html_attributes: {}) ⇒ CaptionComponent

Returns a new instance of CaptionComponent.



6
7
8
9
10
11
12
# File 'app/components/govuk_component/table_component/caption_component.rb', line 6

def initialize(text: nil, id: nil, size: 'm', classes: [], html_attributes: {})
  @id   = id
  @text = text
  @size = size

  super(classes:, html_attributes:)
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



2
3
4
# File 'app/components/govuk_component/table_component/caption_component.rb', line 2

def size
  @size
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'app/components/govuk_component/table_component/caption_component.rb', line 2

def text
  @text
end

Instance Method Details

#callObject



14
15
16
# File 'app/components/govuk_component/table_component/caption_component.rb', line 14

def call
  tag.caption(caption_content, **html_attributes)
end

#render?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/components/govuk_component/table_component/caption_component.rb', line 18

def render?
  caption_content.present?
end