html-table 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES.rdoc → CHANGES.md} +73 -69
  4. data/Gemfile +2 -7
  5. data/{MANIFEST.rdoc → MANIFEST.md} +15 -15
  6. data/{README.rdoc → README.md} +80 -71
  7. data/Rakefile +7 -2
  8. data/doc/attributes.md +160 -0
  9. data/doc/table.md +173 -0
  10. data/doc/table_body.md +9 -0
  11. data/doc/table_caption.md +10 -0
  12. data/doc/table_colgroup.md +8 -0
  13. data/doc/table_colgroup_col.md +7 -0
  14. data/doc/table_content.md +17 -0
  15. data/doc/table_foot.md +8 -0
  16. data/doc/table_head.md +10 -0
  17. data/doc/table_row.md +114 -0
  18. data/doc/table_row_data.md +100 -0
  19. data/doc/table_row_header.md +6 -0
  20. data/examples/simple1.rb +7 -5
  21. data/html-table.gemspec +13 -8
  22. data/lib/html/body.rb +9 -7
  23. data/lib/html/caption.rb +4 -2
  24. data/lib/html/col.rb +37 -34
  25. data/lib/html/colgroup.rb +90 -97
  26. data/lib/html/content.rb +3 -6
  27. data/lib/html/data.rb +3 -1
  28. data/lib/html/foot.rb +53 -45
  29. data/lib/html/head.rb +54 -47
  30. data/lib/html/header.rb +5 -3
  31. data/lib/html/mixin/attribute_handler.rb +57 -53
  32. data/lib/html/mixin/html_handler.rb +33 -35
  33. data/lib/html/mixin/strongtyping.rb +6 -6
  34. data/lib/html/mixin/tag_handler.rb +6 -2
  35. data/lib/html/row.rb +156 -183
  36. data/lib/html/table.rb +45 -45
  37. data/lib/html/tablesection.rb +51 -46
  38. data/spec/attribute_handler_spec.rb +94 -80
  39. data/spec/body_spec.rb +54 -37
  40. data/spec/caption_spec.rb +41 -32
  41. data/spec/colgroup_col_spec.rb +7 -7
  42. data/spec/colgroup_spec.rb +50 -36
  43. data/spec/data_spec.rb +39 -23
  44. data/spec/foot_spec.rb +58 -46
  45. data/spec/head_spec.rb +62 -47
  46. data/spec/header_spec.rb +35 -22
  47. data/spec/html_handler_spec.rb +15 -12
  48. data/spec/row_spec.rb +95 -68
  49. data/spec/table_spec.rb +65 -31
  50. data/spec/tablesection_spec.rb +13 -13
  51. data/spec/tag_handler_spec.rb +13 -13
  52. data.tar.gz.sig +0 -0
  53. metadata +103 -78
  54. metadata.gz.sig +0 -0
  55. data/doc/attributes.rdoc +0 -143
  56. data/doc/table.rdoc +0 -156
  57. data/doc/table_body.rdoc +0 -9
  58. data/doc/table_caption.rdoc +0 -9
  59. data/doc/table_colgroup.rdoc +0 -8
  60. data/doc/table_colgroup_col.rdoc +0 -9
  61. data/doc/table_content.rdoc +0 -15
  62. data/doc/table_foot.rdoc +0 -8
  63. data/doc/table_head.rdoc +0 -11
  64. data/doc/table_row.rdoc +0 -105
  65. data/doc/table_row_data.rdoc +0 -92
  66. data/doc/table_row_header.rdoc +0 -7
data/html-table.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'html-table'
5
- spec.version = '1.7.0'
5
+ spec.version = '1.7.1'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -12,20 +12,25 @@ Gem::Specification.new do |spec|
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
- spec.extra_rdoc_files = ['README.rdoc', 'CHANGES.rdoc'] + Dir['doc/*.rdoc']
15
+ spec.extra_rdoc_files = ['README.md', 'CHANGES.md', 'MANIFEST.md'] + Dir['doc/*.md']
16
16
 
17
17
  spec.add_dependency('structured_warnings', '~> 0.4.0')
18
18
 
19
19
  spec.add_development_dependency('rspec', '~> 3.9')
20
20
  spec.add_development_dependency('rake')
21
+ spec.add_development_dependency('rubocop')
22
+ spec.add_development_dependency('rubocop-rspec')
21
23
 
22
24
  spec.metadata = {
23
- 'homepage_uri' => 'https://github.com/djberg96/html-table',
24
- 'bug_tracker_uri' => 'https://github.com/djberg96/html-table/issues',
25
- 'changelog_uri' => 'https://github.com/djberg96/html-table/blob/master/CHANGES',
26
- 'documentation_uri' => 'https://github.com/djberg96/html-table/wiki',
27
- 'source_code_uri' => 'https://github.com/djberg96/html-table',
28
- 'wiki_uri' => 'https://github.com/djberg96/html-table/wiki'
25
+ 'homepage_uri' => 'https://github.com/djberg96/html-table',
26
+ 'bug_tracker_uri' => 'https://github.com/djberg96/html-table/issues',
27
+ 'changelog_uri' => 'https://github.com/djberg96/html-table/blob/main/CHANGES.md',
28
+ 'documentation_uri' => 'https://djberg96.github.io/html-table',
29
+ 'source_code_uri' => 'https://github.com/djberg96/html-table',
30
+ 'wiki_uri' => 'https://github.com/djberg96/html-table/wiki',
31
+ 'rubygems_mfa_required' => 'true',
32
+ 'github_repo' => 'https://github.com/djberg96/html-table',
33
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
29
34
  }
30
35
 
31
36
  spec.description = <<-EOF
data/lib/html/body.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
-
3
3
  # This class represents an HTML table body (<tbody>). It is a
4
4
  # subclass of Table::TableSection.
5
5
  #
6
6
  class Table::Body < Table::TableSection
7
+ extend HTML::Mixin::StrongTyping
8
+
7
9
  @indent_level = 3
8
10
  @end_tags = true
9
11
 
@@ -11,12 +13,12 @@ module HTML
11
13
  # an argument is provided, it is treated as content.
12
14
  #
13
15
  def initialize(arg = nil, &block)
14
- @html_begin = "<tbody"
15
- @html_end = "</tbody>"
16
- instance_eval(&block) if block_given?
16
+ @html_begin = '<tbody'
17
+ @html_end = '</tbody>'
18
+ super(&block)
17
19
  self.content = arg if arg
18
20
  end
19
-
21
+
20
22
  # Returns a boolean indicating whether or not end tags, </tbody>, are
21
23
  # included for each Body object in the final HTML output. The
22
24
  # default is true.
@@ -24,13 +26,13 @@ module HTML
24
26
  def self.end_tags?
25
27
  @end_tags
26
28
  end
27
-
29
+
28
30
  # Sets whether or not end tags are included for each Body object in
29
31
  # the final HTML output. The default is true. Only true or false are
30
32
  # valid arguments.
31
33
  #
32
34
  def self.end_tags=(bool)
33
- expect(bool,[TrueClass, FalseClass])
35
+ expect(bool, [TrueClass, FalseClass])
34
36
  @end_tags = bool
35
37
  end
36
38
  end
data/lib/html/caption.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
3
 
3
4
  # This class represents an HTML Caption. Despite the name, it is not
@@ -6,6 +7,7 @@ module HTML
6
7
  class Table::Caption
7
8
  include HTML::Mixin::AttributeHandler
8
9
  include HTML::Mixin::HtmlHandler
10
+ extend HTML::Mixin::StrongTyping
9
11
 
10
12
  undef_method :configure
11
13
  @indent_level = 3
@@ -38,8 +40,8 @@ module HTML
38
40
  # Sets the number of spaces that tags for this class are indented.
39
41
  #
40
42
  def self.indent_level=(num)
41
- expect(num,Integer)
42
- raise ArgumentError, "indent level must be >= 0" if num < 0
43
+ expect(num, Integer)
44
+ raise ArgumentError, 'indent level must be >= 0' if num < 0
43
45
  @indent_level = num
44
46
  end
45
47
 
data/lib/html/col.rb CHANGED
@@ -1,41 +1,44 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
- # This class represents an HTML ColGroup column (<col>). Despite the
3
- # name, it is not a subclass of ColGroup or Table.
4
- #
5
- class Table::ColGroup::Col
6
- include HTML::Mixin::AttributeHandler
7
- include HTML::Mixin::HtmlHandler
8
3
 
9
- undef_method :configure, :content
10
- @indent_level = 6
4
+ # This class represents an HTML ColGroup column (<col>). Despite the
5
+ # name, it is not a subclass of ColGroup or Table.
6
+ #
7
+ class Table::ColGroup::Col
8
+ include HTML::Mixin::AttributeHandler
9
+ include HTML::Mixin::HtmlHandler
10
+ extend HTML::Mixin::StrongTyping
11
11
 
12
- # Creates and returns a new ColGroup object. Optionally takes a block.
13
- # Note that it does not accept an argument - col tags do not have content.
14
- #
15
- def initialize(&block)
16
- @html_begin = '<col'
17
- @html_body = ''
18
- @html_end = ''
19
- instance_eval(&block) if block_given?
20
- end
12
+ undef_method :configure, :content
13
+ @indent_level = 6
21
14
 
22
- # Returns the indentation level for the tags of this class. The
23
- # default is 6.
24
- #
25
- def self.indent_level
26
- @indent_level
27
- end
15
+ # Creates and returns a new ColGroup object. Optionally takes a block.
16
+ # Note that it does not accept an argument - col tags do not have content.
17
+ #
18
+ def initialize(&block)
19
+ @html_begin = '<col'
20
+ @html_body = ''
21
+ @html_end = ''
22
+ instance_eval(&block) if block_given?
23
+ end
28
24
 
29
- # Sets the indentation level for the tags of this class. The default
30
- # is 6.
31
- #
32
- def self.indent_level=(num)
33
- expect(num,Integer)
34
- raise ArgumentError, "num must be >= 0" if num < 0
35
- @indent_level = num
36
- end
25
+ # Returns the indentation level for the tags of this class. The
26
+ # default is 6.
27
+ #
28
+ def self.indent_level
29
+ @indent_level
30
+ end
37
31
 
38
- alias to_s html
39
- alias to_str html
40
- end
32
+ # Sets the indentation level for the tags of this class. The default
33
+ # is 6.
34
+ #
35
+ def self.indent_level=(num)
36
+ expect(num, Integer)
37
+ raise ArgumentError, 'num must be >= 0' if num < 0
38
+ @indent_level = num
39
+ end
40
+
41
+ alias to_s html
42
+ alias to_str html
43
+ end
41
44
  end
data/lib/html/colgroup.rb CHANGED
@@ -1,113 +1,106 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
- # This class represents an HTML column group (<colgroup>). It is a
3
- # subclass of Array. The only elements it may contain are instances
4
- # of the ColGroup::Col class.
5
- #
6
- class Table::ColGroup < Array
7
- include HTML::Mixin::AttributeHandler
8
- include HTML::Mixin::HtmlHandler
9
3
 
10
- @indent_level = 3
11
- @end_tags = true
4
+ # This class represents an HTML column group (<colgroup>). It is a
5
+ # subclass of Array. The only elements it may contain are instances
6
+ # of the ColGroup::Col class.
7
+ #
8
+ class Table::ColGroup < Array
9
+ include HTML::Mixin::AttributeHandler
10
+ include HTML::Mixin::HtmlHandler
11
+ include HTML::Mixin::StrongTyping
12
+ extend HTML::Mixin::StrongTyping
12
13
 
13
- undef_method :content
14
+ @indent_level = 3
15
+ @end_tags = true
14
16
 
15
- # Returns a new ColGroup object. Optionally takes a block. If an
16
- # argument is provided, it is treated as content.
17
- #
18
- def initialize(arg = nil, &block)
19
- @html_begin = '<colgroup'
20
- @html_body = ''
21
- @html_end = '</colgroup>'
22
- instance_eval(&block) if block_given?
23
- self.push(arg) if arg
24
- end
17
+ undef_method :content
25
18
 
26
- # Returns the indentation level for the tags of this class. The
27
- # default is 3.
28
- #
29
- def self.indent_level
30
- @indent_level
31
- end
19
+ # Returns a new ColGroup object. Optionally takes a block. If an
20
+ # argument is provided, it is treated as content.
21
+ #
22
+ def initialize(arg = nil, &block)
23
+ @html_begin = '<colgroup'
24
+ @html_body = ''
25
+ @html_end = '</colgroup>'
26
+ super(&block)
27
+ push(arg) if arg
28
+ end
32
29
 
33
- # Sets the indentation level for the tags of this class. The default
34
- # is 3.
35
- #
36
- def self.indent_level=(num)
37
- expect(num,Integer)
38
- raise ArgumentError,"indent_level must be >= 0" if num < 0
39
- @indent_level = num
40
- end
30
+ # Returns the indentation level for the tags of this class. The
31
+ # default is 3.
32
+ #
33
+ def self.indent_level
34
+ @indent_level
35
+ end
41
36
 
42
- # This method has been redefined to only allow ColGroup::Col objects
43
- # to be assigned.
44
- #
45
- def []=(index,obj)
46
- if obj.kind_of?(Array)
47
- expect(obj.first,Col) # In case of 0 length Array
48
- obj.each{ |o|
49
- expect(o,Col)
50
- }
51
- else
52
- expect(obj,Col)
53
- end
54
- super
55
- end
37
+ # Sets the indentation level for the tags of this class. The default
38
+ # is 3.
39
+ #
40
+ def self.indent_level=(num)
41
+ expect(num, Integer)
42
+ raise ArgumentError, 'indent_level must be >= 0' if num < 0
43
+ @indent_level = num
44
+ end
56
45
 
57
- # This method has been redefined to only allow ColGroup::Col objects
58
- # to be pushed onto a ColGroup instance.
59
- #
60
- def push(*args)
61
- args.each do |obj|
62
- unless obj.kind_of?(Table::ColGroup::Col)
63
- msg = "Can only assign Col objects to ColGroup class"
64
- msg += ": " + obj.class.to_s
65
- raise TypeError, msg
66
- end
67
- super(obj)
68
- end
46
+ # This method has been redefined to only allow ColGroup::Col objects
47
+ # to be assigned.
48
+ #
49
+ def []=(index, obj)
50
+ if obj.is_a?(Array)
51
+ expect(obj.first, Col) # In case of 0 length Array
52
+ obj.each do |o|
53
+ expect(o, Col)
54
+ end
55
+ else
56
+ expect(obj, Col)
69
57
  end
58
+ super
59
+ end
70
60
 
71
- # This method has been redefined to only allow ColGroup::Col objects
72
- # to be pushed onto a ColGroup instance.
73
- #
74
- def <<(obj)
75
- unless obj.kind_of?(Table::ColGroup::Col)
76
- msg = "Can only assign Col objects to ColGroup class"
77
- msg += ": " + obj.class.to_s
78
- raise TypeError, msg
79
- end
80
- super(obj)
61
+ # This method has been redefined to only allow ColGroup::Col objects
62
+ # to be pushed onto a ColGroup instance.
63
+ #
64
+ def push(*args)
65
+ args.each do |obj|
66
+ expect(obj, Table::ColGroup::Col)
67
+ super(obj)
81
68
  end
69
+ end
82
70
 
83
- # This method has been redefined to only allow ColGroup::Col objects
84
- # to be unshifted onto a ColGroup instance.
85
- #
86
- def unshift(obj)
87
- unless obj.kind_of?(Table::ColGroup::Col)
88
- msg = "Can only assign Data and Header objects to Row class"
89
- raise TypeError, msg
90
- end
91
- super
92
- end
71
+ # This method has been redefined to only allow ColGroup::Col objects
72
+ # to be pushed onto a ColGroup instance.
73
+ #
74
+ def <<(obj)
75
+ expect(obj, Table::ColGroup::Col)
76
+ super
77
+ end
93
78
 
94
- # Returns a boolean indicating whether or not end tags are included for
95
- # each ColGroup object in the final HTML output. The default is true.
96
- #
97
- def self.end_tags?
98
- @end_tags
99
- end
79
+ # This method has been redefined to only allow ColGroup::Col objects
80
+ # to be unshifted onto a ColGroup instance.
81
+ #
82
+ def unshift(obj)
83
+ expect(obj, Table::ColGroup::Col)
84
+ super
85
+ end
100
86
 
101
- # Sets whether or not end tags are included for each ColGroup object in
102
- # the final HTML output. The default is true. Only true or false are
103
- # valid arguments.
104
- #
105
- def self.end_tags=(bool)
106
- expect(bool,[TrueClass,FalseClass])
107
- @end_tags = bool
108
- end
87
+ # Returns a boolean indicating whether or not end tags are included for
88
+ # each ColGroup object in the final HTML output. The default is true.
89
+ #
90
+ def self.end_tags?
91
+ @end_tags
92
+ end
93
+
94
+ # Sets whether or not end tags are included for each ColGroup object in
95
+ # the final HTML output. The default is true. Only true or false are
96
+ # valid arguments.
97
+ #
98
+ def self.end_tags=(bool)
99
+ expect(bool, [TrueClass, FalseClass])
100
+ @end_tags = bool
101
+ end
109
102
 
110
- alias to_s html
111
- alias to_str html
112
- end
103
+ alias to_s html
104
+ alias to_str html
105
+ end
113
106
  end
data/lib/html/content.rb CHANGED
@@ -1,12 +1,9 @@
1
- ########################################################################
2
- # content.rb
3
- #
4
- # This class handles content for Table::Row::Data, Table::Row::Header,
5
- # and Table::Row::Caption objects.
6
- ########################################################################
7
1
  require_relative 'mixin/tag_handler'
8
2
 
3
+ # The HTML module is a namespace only.
9
4
  module HTML
5
+ # The Table::Content class handles content for Table::Row::Data,
6
+ # Table::Row::Header, and Table::Row::Caption objects.
10
7
  class Table::Content < String
11
8
  include HTML::Mixin::TagHandler
12
9
 
data/lib/html/data.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
3
 
3
4
  # This class represents HTML table data, <td>. Despite the name
@@ -6,6 +7,7 @@ module HTML
6
7
  class Table::Row::Data
7
8
  include HTML::Mixin::AttributeHandler
8
9
  include HTML::Mixin::HtmlHandler
10
+ extend HTML::Mixin::StrongTyping
9
11
 
10
12
  undef_method :configure
11
13
 
@@ -42,7 +44,7 @@ module HTML
42
44
  #
43
45
  def self.indent_level=(num)
44
46
  expect(num, Integer)
45
- raise ArgumentError,"indent_level must be >= 0" if num < 0
47
+ raise ArgumentError, 'indent_level must be >= 0' if num < 0
46
48
  @indent_level = num
47
49
  end
48
50
 
data/lib/html/foot.rb CHANGED
@@ -1,49 +1,57 @@
1
+ require 'singleton'
2
+
3
+ # The HTML module serves as a namespace only.
1
4
  module HTML
2
5
 
3
- # This class represents an HTML table foot (<tfoot>). It is a
4
- # subclass of Table::TableSection. It is a singleton class.
5
- #
6
- class Table::Foot < Table::TableSection
7
- private_class_method :new
8
-
9
- @@foot = nil
10
- @indent_level = 3
11
- @end_tags = true
12
-
13
- # This is our constructor for Foot objects because it is a singleton
14
- # class. Optionally, a block may be provided. If an argument is
15
- # provided it is treated as content.
16
- #
17
- def self.create(arg=nil, &block)
18
- @@foot = new(arg, &block) unless @@foot
19
- @@foot
20
- end
21
-
22
- # Called by create() instead of new(). This initializes the Foot class.
23
- #
24
- def initialize(arg, &block)
25
- @html_begin = "<tfoot"
26
- @html_end = "</tfoot>"
27
- instance_eval(&block) if block_given?
28
- self.content = arg if arg
29
- end
30
-
31
- # Returns a boolean indicating whether or not end tags, </tfoot>, are
32
- # included for each Foot object in the final HTML output. The
33
- # default is true.
34
- #
35
- def self.end_tags?
36
- @end_tags
37
- end
38
-
39
- # Sets whether or not end tags are included for each Foot object in
40
- # the final HTML output. The default is true. Only true or false are
41
- # valid arguments.
42
- #
43
- def self.end_tags=(bool)
44
- expect(bool, [TrueClass,FalseClass])
45
- @end_tags = bool
46
- end
47
- end
6
+ # This class represents an HTML table foot (<tfoot>). It is a
7
+ # subclass of Table::TableSection. It is a singleton class.
8
+ #
9
+ class Table::Foot < Table::TableSection
10
+ include Singleton
11
+ extend HTML::Mixin::StrongTyping
12
+
13
+ @indent_level = 3
14
+ @end_tags = true
15
+
16
+ # This is our constructor for Foot objects because it is a singleton
17
+ # class. Optionally, a block may be provided. If an argument is
18
+ # provided it is treated as content.
19
+ #
20
+ def self.create(arg = nil, &block)
21
+ instance(arg, &block)
22
+ end
23
+
24
+ # Part of the singleton interface.
25
+ #
26
+ def self.instance(arg = nil, &block)
27
+ @instance ||= new(arg, &block)
28
+ end
29
+
30
+ # Called by create() instead of new(). This initializes the Foot class.
31
+ #
32
+ def initialize(arg, &block)
33
+ @html_begin = '<tfoot'
34
+ @html_end = '</tfoot>'
35
+ super(&block)
36
+ self.content = arg if arg
37
+ end
38
+
39
+ # Returns a boolean indicating whether or not end tags, </tfoot>, are
40
+ # included for each Foot object in the final HTML output. The
41
+ # default is true.
42
+ #
43
+ def self.end_tags?
44
+ @end_tags
45
+ end
46
+
47
+ # Sets whether or not end tags are included for each Foot object in
48
+ # the final HTML output. The default is true. Only true or false are
49
+ # valid arguments.
50
+ #
51
+ def self.end_tags=(bool)
52
+ expect(bool, [TrueClass, FalseClass])
53
+ @end_tags = bool
54
+ end
55
+ end
48
56
 
49
57
  end
data/lib/html/head.rb CHANGED
@@ -1,49 +1,56 @@
1
+ require 'singleton'
2
+
3
+ # The HTML module serves only as a namespace.
1
4
  module HTML
2
-
3
- # This class represents an HTML table head (<thead>). It is a
4
- # subclass of Table::TableSection. It is a singleton class.
5
- #
6
- class Table::Head < Table::TableSection
7
- private_class_method :new
8
-
9
- @@head = nil
10
-
11
- @indent_level = 3
12
- @end_tags = true
13
-
14
- # This is our constructor for Head objects because it is a singleton
15
- # class. Optionally, a block may be provided. If an argument is
16
- # provided it is treated as content.
17
- #
18
- def self.create(arg=nil, &block)
19
- @@head = new(arg, &block) unless @@head
20
- @@head
21
- end
22
-
23
- # Called by create() instead of new(). This initializes the Head class.
24
- #
25
- def initialize(arg, &block)
26
- @html_begin = "<thead"
27
- @html_end = "</thead>"
28
- instance_eval(&block) if block_given?
29
- self.content = arg if arg
30
- end
31
-
32
- # Returns a boolean indicating whether or not end tags, </thead>, are
33
- # included for each Head object in the final HTML output. The
34
- # default is true.
35
- #
36
- def self.end_tags?
37
- @end_tags
38
- end
39
-
40
- # Sets whether or not end tags are included for each Head object in
41
- # the final HTML output. The default is true. Only true or false are
42
- # valid arguments.
43
- #
44
- def self.end_tags=(bool)
45
- expect(bool,[TrueClass,FalseClass])
46
- @end_tags = bool
47
- end
48
- end
5
+
6
+ # This class represents an HTML table head (<thead>). It is a
7
+ # subclass of Table::TableSection. It is a singleton class.
8
+ #
9
+ class Table::Head < Table::TableSection
10
+ include Singleton
11
+ extend HTML::Mixin::StrongTyping
12
+
13
+ @indent_level = 3
14
+ @end_tags = true
15
+
16
+ # This is our constructor for Head objects because it is a singleton
17
+ # class. Optionally, a block may be provided. If an argument is
18
+ # provided it is treated as content.
19
+ #
20
+ def self.create(arg = nil, &block)
21
+ instance(arg, &block)
22
+ end
23
+
24
+ # Part of the singleton interface.
25
+ #
26
+ def self.instance(arg = nil, &block)
27
+ @instance ||= new(arg, &block)
28
+ end
29
+
30
+ # Called by create() instead of new(). This initializes the Head class.
31
+ #
32
+ def initialize(arg, &block)
33
+ @html_begin = '<thead'
34
+ @html_end = '</thead>'
35
+ super(&block)
36
+ self.content = arg if arg
37
+ end
38
+
39
+ # Returns a boolean indicating whether or not end tags, </thead>, are
40
+ # included for each Head object in the final HTML output. The
41
+ # default is true.
42
+ #
43
+ def self.end_tags?
44
+ @end_tags
45
+ end
46
+
47
+ # Sets whether or not end tags are included for each Head object in
48
+ # the final HTML output. The default is true. Only true or false are
49
+ # valid arguments.
50
+ #
51
+ def self.end_tags=(bool)
52
+ expect(bool, [TrueClass, FalseClass])
53
+ @end_tags = bool
54
+ end
55
+ end
49
56
  end