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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +73 -69
- data/Gemfile +2 -7
- data/{MANIFEST.rdoc → MANIFEST.md} +15 -15
- data/{README.rdoc → README.md} +80 -71
- data/Rakefile +7 -2
- data/doc/attributes.md +160 -0
- data/doc/table.md +173 -0
- data/doc/table_body.md +9 -0
- data/doc/table_caption.md +10 -0
- data/doc/table_colgroup.md +8 -0
- data/doc/table_colgroup_col.md +7 -0
- data/doc/table_content.md +17 -0
- data/doc/table_foot.md +8 -0
- data/doc/table_head.md +10 -0
- data/doc/table_row.md +114 -0
- data/doc/table_row_data.md +100 -0
- data/doc/table_row_header.md +6 -0
- data/examples/simple1.rb +7 -5
- data/html-table.gemspec +13 -8
- data/lib/html/body.rb +9 -7
- data/lib/html/caption.rb +4 -2
- data/lib/html/col.rb +37 -34
- data/lib/html/colgroup.rb +90 -97
- data/lib/html/content.rb +3 -6
- data/lib/html/data.rb +3 -1
- data/lib/html/foot.rb +53 -45
- data/lib/html/head.rb +54 -47
- data/lib/html/header.rb +5 -3
- data/lib/html/mixin/attribute_handler.rb +57 -53
- data/lib/html/mixin/html_handler.rb +33 -35
- data/lib/html/mixin/strongtyping.rb +6 -6
- data/lib/html/mixin/tag_handler.rb +6 -2
- data/lib/html/row.rb +156 -183
- data/lib/html/table.rb +45 -45
- data/lib/html/tablesection.rb +51 -46
- data/spec/attribute_handler_spec.rb +94 -80
- data/spec/body_spec.rb +54 -37
- data/spec/caption_spec.rb +41 -32
- data/spec/colgroup_col_spec.rb +7 -7
- data/spec/colgroup_spec.rb +50 -36
- data/spec/data_spec.rb +39 -23
- data/spec/foot_spec.rb +58 -46
- data/spec/head_spec.rb +62 -47
- data/spec/header_spec.rb +35 -22
- data/spec/html_handler_spec.rb +15 -12
- data/spec/row_spec.rb +95 -68
- data/spec/table_spec.rb +65 -31
- data/spec/tablesection_spec.rb +13 -13
- data/spec/tag_handler_spec.rb +13 -13
- data.tar.gz.sig +0 -0
- metadata +103 -78
- metadata.gz.sig +0 -0
- data/doc/attributes.rdoc +0 -143
- data/doc/table.rdoc +0 -156
- data/doc/table_body.rdoc +0 -9
- data/doc/table_caption.rdoc +0 -9
- data/doc/table_colgroup.rdoc +0 -8
- data/doc/table_colgroup_col.rdoc +0 -9
- data/doc/table_content.rdoc +0 -15
- data/doc/table_foot.rdoc +0 -8
- data/doc/table_head.rdoc +0 -11
- data/doc/table_row.rdoc +0 -105
- data/doc/table_row_data.rdoc +0 -92
- 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.
|
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.
|
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'
|
24
|
-
'bug_tracker_uri'
|
25
|
-
'changelog_uri'
|
26
|
-
'documentation_uri'
|
27
|
-
'source_code_uri'
|
28
|
-
'wiki_uri'
|
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 =
|
15
|
-
@html_end =
|
16
|
-
|
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,
|
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
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
11
|
-
|
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
|
-
|
14
|
+
@indent_level = 3
|
15
|
+
@end_tags = true
|
14
16
|
|
15
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
-
|
111
|
-
|
112
|
-
|
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,
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|