Class: HTML::Table::ColGroup

Inherits:
Array
  • Object
show all
Extended by:
Mixin::StrongTyping
Includes:
Mixin::AttributeHandler, Mixin::HtmlHandler, Mixin::StrongTyping
Defined in:
lib/html/colgroup.rb

Overview

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.

Defined Under Namespace

Classes: Col

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin::StrongTyping

expect

Methods included from Mixin::HtmlHandler

#html

Methods included from Mixin::AttributeHandler

#abbr, #abbr=, #align, #align=, #axis, #axis=, #background, #background=, #bgcolor, #bgcolor=, #border, #border=, #bordercolor, #bordercolor=, #bordercolordark, #bordercolordark=, #bordercolorlight, #bordercolorlight=, #cellpadding, #cellpadding=, #cellspacing, #cellspacing=, #char, #char=, #charoff, #charoff=, #class_, #class_=, #col, #col=, #colspan, #colspan=, #configure, #content, #frame, #frame=, #height, #height=, #hspace, #hspace=, #nowrap, #nowrap=, #rowspan, #rowspan=, #rules, #rules=, #span, #span=, #style, #style=, #summary, #summary=, #valign, #valign=, #vspace, #vspace=, #width, #width=

Constructor Details

#initialize(arg = nil, &block) ⇒ ColGroup

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



22
23
24
25
26
27
28
# 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

Class Method Details

.end_tags=(bool) ⇒ Object

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.



98
99
100
101
# File 'lib/html/colgroup.rb', line 98

def self.end_tags=(bool)
  expect(bool, [TrueClass, FalseClass])
  @end_tags = bool
end

.end_tags?Boolean

Returns a boolean indicating whether or not end tags are included for each ColGroup object in the final HTML output. The default is true.

Returns:

  • (Boolean)


90
91
92
# File 'lib/html/colgroup.rb', line 90

def self.end_tags?
  @end_tags
end

.indent_levelObject

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



33
34
35
# File 'lib/html/colgroup.rb', line 33

def self.indent_level
  @indent_level
end

.indent_level=(num) ⇒ Object

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

Raises:

  • (ArgumentError)


40
41
42
43
44
# 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

Instance Method Details

#<<(obj) ⇒ Object

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



74
75
76
77
# File 'lib/html/colgroup.rb', line 74

def <<(obj)
  expect(obj, Table::ColGroup::Col)
  super
end

#[]=(index, obj) ⇒ Object

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



49
50
51
52
53
54
55
56
57
58
59
# 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) ⇒ Object

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



64
65
66
67
68
69
# File 'lib/html/colgroup.rb', line 64

def push(*args)
  args.each do |obj|
    expect(obj, Table::ColGroup::Col)
    super(obj)
  end
end

#unshift(obj) ⇒ Object

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



82
83
84
85
# File 'lib/html/colgroup.rb', line 82

def unshift(obj)
  expect(obj, Table::ColGroup::Col)
  super
end