Class: Coradoc::Element::Table::Row

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/element/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

access_children, #children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit

Constructor Details

#initialize(columns, header = false) ⇒ Row

Returns a new instance of Row.



30
31
32
33
# File 'lib/coradoc/element/table.rb', line 30

def initialize(columns, header = false)
  @columns = columns
  @header = header
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



26
27
28
# File 'lib/coradoc/element/table.rb', line 26

def columns
  @columns
end

#headerObject

Returns the value of attribute header.



26
27
28
# File 'lib/coradoc/element/table.rb', line 26

def header
  @header
end

Instance Method Details

#asciidoc?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/coradoc/element/table.rb', line 39

def asciidoc?
  @columns.any? { |c| c.respond_to?(:asciidoc?) && c.asciidoc? }
end

#table_header_row?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/coradoc/element/table.rb', line 35

def table_header_row?
  @header
end

#to_adocObject



43
44
45
46
47
48
49
50
51
# File 'lib/coradoc/element/table.rb', line 43

def to_adoc
  delim = asciidoc? ? "\n" : " "
  content = @columns.map do |col|
    Coradoc::Generator.gen_adoc(col)
  end.join(delim)
  result  = "#{content}\n"
  result << "\n" if asciidoc?
  table_header_row? ? result + underline_for : result
end

#underline_forObject



53
54
55
# File 'lib/coradoc/element/table.rb', line 53

def underline_for
  "\n"
end