Class: GovukComponent::InsetTextComponent

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

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, classes: [], html_attributes: {}) ⇒ InsetTextComponent

Returns a new instance of InsetTextComponent.



4
5
6
7
8
9
# File 'app/components/govuk_component/inset_text_component.rb', line 4

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

  super(classes:, html_attributes:)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#callObject



11
12
13
# File 'app/components/govuk_component/inset_text_component.rb', line 11

def call
  tag.div(id:, **html_attributes) { inset_text_content }
end

#render?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/components/govuk_component/inset_text_component.rb', line 15

def render?
  inset_text_content.present?
end