Class: GovukComponent::TableComponent::CellComponent

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

Constant Summary collapse

WIDTHS =
{
  "full"           => "govuk-!-width-full",
  "three-quarters" => "govuk-!-width-three-quarters",
  "two-thirds"     => "govuk-!-width-two-thirds",
  "one-half"       => "govuk-!-width-one-half",
  "one-third"      => "govuk-!-width-one-third",
  "one-quarter"    => "govuk-!-width-one-quarter",
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(scope: nil, header: nil, numeric: false, text: nil, width: nil, parent: nil, rowspan: nil, colspan: nil, classes: [], html_attributes: {}) ⇒ CellComponent

Returns a new instance of CellComponent.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/components/govuk_component/table_component/cell_component.rb', line 16

def initialize(scope: nil, header: nil, numeric: false, text: nil, width: nil, parent: nil, rowspan: nil, colspan: nil, classes: [], html_attributes: {})
  @text    = text
  @numeric = numeric
  @width   = width
  @scope   = scope
  @parent  = parent
  @colspan = colspan
  @rowspan = rowspan
  @header  = (header.nil?) ? in_thead? : header

  super(classes: classes, html_attributes: html_attributes)
end

Instance Attribute Details

#colspanObject (readonly)

Returns the value of attribute colspan.



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

def colspan
  @colspan
end

#headerObject (readonly) Also known as: header?

Returns the value of attribute header.



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

def header
  @header
end

#numericObject (readonly) Also known as: numeric?

Returns the value of attribute numeric.



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

def numeric
  @numeric
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

#rowspanObject (readonly)

Returns the value of attribute rowspan.



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

def rowspan
  @rowspan
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#callObject



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

def call
  (cell_element, cell_content, **html_attributes)
end