Class: GovukComponent::TableComponent::RowComponent

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

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(cell_data: nil, first_cell_is_header: false, parent: nil, classes: [], html_attributes: {}) ⇒ RowComponent

Returns a new instance of RowComponent.



20
21
22
23
24
25
26
27
# File 'app/components/govuk_component/table_component/row_component.rb', line 20

def initialize(cell_data: nil, first_cell_is_header: false, parent: nil, classes: [], html_attributes: {})
  @first_cell_is_header = first_cell_is_header
  @parent = parent

  super(classes:, html_attributes:)

  build_cells_from_cell_data(cell_data)
end

Instance Attribute Details

#first_cell_is_headerObject (readonly)

Returns the value of attribute first_cell_is_header.



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

def first_cell_is_header
  @first_cell_is_header
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

Class Method Details

.from_body(*args, **kwargs, &block) ⇒ Object



33
34
35
# File 'app/components/govuk_component/table_component/row_component.rb', line 33

def self.from_body(*args, **kwargs, &block)
  new(*args, parent: 'tbody', **kwargs, &block)
end

.from_foot(*args, **kwargs, &block) ⇒ Object



37
38
39
# File 'app/components/govuk_component/table_component/row_component.rb', line 37

def self.from_foot(*args, **kwargs, &block)
  new(*args, parent: 'tfoot', **kwargs, &block)
end

.from_head(*args, **kwargs, &block) ⇒ Object



29
30
31
# File 'app/components/govuk_component/table_component/row_component.rb', line 29

def self.from_head(*args, **kwargs, &block)
  new(*args, parent: 'thead', **kwargs, &block)
end

Instance Method Details

#callObject



41
42
43
# File 'app/components/govuk_component/table_component/row_component.rb', line 41

def call
  tag.tr(**html_attributes) { safe_join(cells) }
end