class HTML::Table::ColGroup

This class represents an HTML column group (<colgroup>). It is a subclass of Array. The only elements it may contain are instances of the ColGroup::Col class.

Public Class Methods

end_tags=(bool) click to toggle source

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

# File lib/html/colgroup.rb, line 109
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 are included for each ColGroup object in the final HTML output. The default is true.

# File lib/html/colgroup.rb, line 101
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 3.

# File lib/html/colgroup.rb, line 33
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 3.

# File lib/html/colgroup.rb, line 40
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

Returns a new ColGroup object. Optionally takes a block. If an argument is provided, it is treated as content.

Calls superclass method
# File lib/html/colgroup.rb, line 22
def initialize(arg = nil, &block)
  @html_begin = '<colgroup'
  @html_body  = ''
  @html_end   = '</colgroup>'
  super(&block)
  push(arg) if arg
end

Public Instance Methods

<<(obj) click to toggle source

This method has been redefined to only allow ColGroup::Col objects to be pushed onto a ColGroup instance.

Calls superclass method
# File lib/html/colgroup.rb, line 78
def <<(obj)
  unless obj.is_a?(Table::ColGroup::Col)
    msg = 'Can only assign Col objects to ColGroup class'
    msg += ": #{obj.class}"
    raise TypeError, msg
  end
  super(obj)
end
[]=(index, obj) click to toggle source

This method has been redefined to only allow ColGroup::Col objects to be assigned.

Calls superclass method
# File lib/html/colgroup.rb, line 49
def []=(index, obj)
  if obj.is_a?(Array)
    expect(obj.first, Col) # In case of 0 length Array
    obj.each do |o|
      expect(o, Col)
    end
  else
    expect(obj, Col)
  end
  super
end
push(*args) click to toggle source

This method has been redefined to only allow ColGroup::Col objects to be pushed onto a ColGroup instance.

Calls superclass method
# File lib/html/colgroup.rb, line 64
def push(*args)
  args.each do |obj|
    unless obj.is_a?(Table::ColGroup::Col)
      msg = 'Can only assign Col objects to ColGroup class'
      msg += ": #{obj.class}"
      raise TypeError, msg
    end
    super(obj)
  end
end
unshift(obj) click to toggle source

This method has been redefined to only allow ColGroup::Col objects to be unshifted onto a ColGroup instance.

Calls superclass method
# File lib/html/colgroup.rb, line 90
def unshift(obj)
  unless obj.is_a?(Table::ColGroup::Col)
    msg = 'Can only assign Data and Header objects to Row class'
    raise TypeError, msg
  end
  super
end