Class: Coradoc::Element::Table::Cell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(options = {}) ⇒ Cell

Returns a new instance of Cell.



61
62
63
64
65
66
67
68
69
# File 'lib/coradoc/element/table.rb', line 61

def initialize(options = {})
  super()
  @id = options.fetch(:id, nil)
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
  @colrowattr = options.fetch(:colrowattr, "")
  @alignattr = options.fetch(:alignattr, "")
  @style = options.fetch(:style, "")
  @content = options.fetch(:content, "")
end

Instance Attribute Details

#alignattrObject

Returns the value of attribute alignattr.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def alignattr
  @alignattr
end

#anchorObject

Returns the value of attribute anchor.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def anchor
  @anchor
end

#colrowattrObject

Returns the value of attribute colrowattr.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def colrowattr
  @colrowattr
end

#contentObject

Returns the value of attribute content.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def content
  @content
end

#idObject

Returns the value of attribute id.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def id
  @id
end

#styleObject

Returns the value of attribute style.



57
58
59
# File 'lib/coradoc/element/table.rb', line 57

def style
  @style
end

Instance Method Details

#asciidoc?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/coradoc/element/table.rb', line 71

def asciidoc?
  @style.include?("a")
end

#to_adocObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/coradoc/element/table.rb', line 75

def to_adoc
  anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s
  content = simplify_block_content(@content)
  content = Coradoc::Generator.gen_adoc(content)
  # Only try to postprocess elements that are text,
  # otherwise we could strip markup.
  if Coradoc.a_single?(@content, Coradoc::Element::TextElement)
    content = Coradoc.strip_unicode(content)
  end
  "#{@colrowattr}#{@alignattr}#{@style}| #{anchor}#{content}"
end