Class: GovukComponent::TableComponent::CellComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/table_component/cell_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(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.



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

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:, 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

Class Method Details

.widthsObject



7
8
9
10
11
12
13
14
15
16
# File 'app/components/govuk_component/table_component/cell_component.rb', line 7

def self.widths
  {
    "full"           => "#{brand}-!-width-full",
    "three-quarters" => "#{brand}-!-width-three-quarters",
    "two-thirds"     => "#{brand}-!-width-two-thirds",
    "one-half"       => "#{brand}-!-width-one-half",
    "one-third"      => "#{brand}-!-width-one-third",
    "one-quarter"    => "#{brand}-!-width-one-quarter",
  }.freeze
end

Instance Method Details

#callObject



31
32
33
# File 'app/components/govuk_component/table_component/cell_component.rb', line 31

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