Class: Kitchen::Directions::BakeTableBody::V1::CustomBody

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_numbered_table/bake_table_body.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table:, klass:, fake_title_class: nil, fake_title: nil, to_trash: nil) ⇒ CustomBody

Returns a new instance of CustomBody.



17
18
19
20
21
22
23
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 17

def initialize(table:, klass:, fake_title_class: nil, fake_title: nil, to_trash: nil)
  @table = table
  @klass = klass
  @fake_title_class = fake_title_class
  @fake_title = fake_title
  @to_trash = to_trash
end

Instance Attribute Details

#fake_titleObject (readonly)

Returns the value of attribute fake_title.



14
15
16
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 14

def fake_title
  @fake_title
end

#fake_title_classObject (readonly)

Returns the value of attribute fake_title_class.



13
14
15
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 13

def fake_title_class
  @fake_title_class
end

#klassObject (readonly)

Returns the value of attribute klass.



12
13
14
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 12

def klass
  @klass
end

#tableObject (readonly)

Returns the value of attribute table.



11
12
13
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 11

def table
  @table
end

#to_trashObject (readonly)

Returns the value of attribute to_trash.



15
16
17
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 15

def to_trash
  @to_trash
end

Instance Method Details

#modify_body(has_fake_title: false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kitchen/directions/bake_numbered_table/bake_table_body.rb', line 25

def modify_body(has_fake_title: false)
  @table.parent.add_class("os-#{@klass}-container")

  return unless has_fake_title

  @table.prepend(sibling:
    <<~HTML
      <div class="#{@fake_title_class}">#{@fake_title}</div>
    HTML
  )
  @to_trash.trash
end