class HTML::Table::Row::Data

This class represents HTML table data, <td>. Despite the name it is not a subclass of Table::Row or Table.

Public Class Methods

end_tags=(bool) click to toggle source

Sets whether or not end tags are included for each Data object in the final HTML output. The default is true. Only true or false are valid arguments.

# File lib/html/data.rb, line 63
def self.end_tags=(bool)
  expect(bool, [TrueClass, FalseClass])
  @end_tags = bool
end
end_tags?() click to toggle source

Returns a boolean indicating whether or not end tags, </td>, are included for each Data object in the final HTML output. The default is true.

# File lib/html/data.rb, line 55
def self.end_tags?
  @end_tags
end
indent_level() click to toggle source

Returns the indentation level for the tags of this class. The default is 6.

# File lib/html/data.rb, line 38
def self.indent_level
  @indent_level
end
indent_level=(num) click to toggle source

Sets the indentation level for the tags of this class. The default is 6.

# File lib/html/data.rb, line 45
def self.indent_level=(num)
  expect(num, Integer)
  raise ArgumentError, 'indent_level must be >= 0' if num < 0
  @indent_level = num
end
new(arg = nil, &block) click to toggle source

Creates and returns a Data object. Optionally takes a block. If an argument is provided, it is treated as content.

# File lib/html/data.rb, line 20
def initialize(arg = nil, &block)
  @html_begin = '<td'
  @html_body  = ''
  @html_end   = '</td>'
  instance_eval(&block) if block_given?
  self.content = arg if arg
end

Public Instance Methods

content=(arg) click to toggle source

Adds content to the Table::Row::Data object.

# File lib/html/data.rb, line 30
def content=(arg)
  arg = arg.is_a?(Array) ? arg.join : arg.to_s
  @html_body = Table::Content.new(arg)
end