Class: BasicBlock::Table::TabCell

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_iec/basic_block/table.rb

Direct Known Subclasses

Td, Th

Constant Summary collapse

ALIGNS =
%w[left right ceter].freeze
VALIGNS =
%w[top middle bottom baseline].freeze

Instance Method Summary collapse

Constructor Details

#initialize(content, **args) ⇒ TabCell

Returns a new instance of TabCell.

Parameters:

Options Hash (**args):

  • :colspan (String, nil)
  • :rowspan (String, nil)
  • :align (String, nil)
  • :valign (String, nil)


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/relaton_iec/basic_block/table.rb', line 75

def initialize(content, **args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  if args[:align] && !ALIGNS.include?(args[:align])
    Util.warn "invalid table/tr/td align `#{args[:align]}`\n" \
      "alloved aligns are: `#{ALIGNS.join '`, `'}`"
  end
  if args[:valign] && !VALIGNS.include?(args[:valign])
    Util.warn "invalid table/tr/td valign `#{args[:valign]}`\n" \
      "alloved valigns are: `#{VALIGNS.join '`, `'}`"
  end
  @content = content
  @colspan = args[:colspan]
  @rowspan = args[:rowspan]
  @align = args[:align]
  @valign = args[:valign]
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


92
93
94
95
96
97
98
# File 'lib/relaton_iec/basic_block/table.rb', line 92

def to_xml(builder)
  td = @content.each { |c| c.to_xml builder }
  td[:colspan] = @colspan if @colspan
  td[:rowspan] = @rowspan if @rowspan
  td[:align] = @align if @align
  td[:valign] = @valign if @valign
end