html-table 1.4.2 → 1.5.0
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.tar.gz.sig +0 -0
- data/CHANGES +155 -149
- data/MANIFEST +59 -59
- data/README +132 -132
- data/certs/djberg96_pub.pem +15 -15
- data/doc/attributes.rdoc +143 -143
- data/doc/table.rdoc +158 -158
- data/doc/table_body.rdoc +9 -9
- data/doc/table_caption.rdoc +9 -9
- data/doc/table_colgroup.rdoc +8 -8
- data/doc/table_colgroup_col.rdoc +9 -9
- data/doc/table_content.rdoc +15 -15
- data/doc/table_foot.rdoc +8 -8
- data/doc/table_head.rdoc +11 -11
- data/doc/table_row.rdoc +105 -105
- data/doc/table_row_data.rdoc +92 -92
- data/doc/table_row_header.rdoc +7 -7
- data/examples/advanced.rb +128 -128
- data/examples/intermediate1.rb +72 -72
- data/examples/intermediate2.rb +62 -62
- data/examples/intermediate3.rb +46 -46
- data/examples/simple1.rb +39 -39
- data/examples/simple2.rb +47 -47
- data/examples/simple3.rb +41 -41
- data/html-table.gemspec +28 -28
- data/lib/html-table.rb +1 -1
- data/lib/html/attribute_handler.rb +403 -403
- data/lib/html/body.rb +37 -37
- data/lib/html/caption.rb +49 -49
- data/lib/html/col.rb +41 -41
- data/lib/html/colgroup.rb +113 -113
- data/lib/html/content.rb +18 -18
- data/lib/html/data.rb +69 -69
- data/lib/html/foot.rb +49 -49
- data/lib/html/head.rb +49 -49
- data/lib/html/header.rb +65 -65
- data/lib/html/html_handler.rb +120 -120
- data/lib/html/row.rb +188 -188
- data/lib/html/table.rb +323 -323
- data/lib/html/tablesection.rb +48 -48
- data/lib/html/tag_handler.rb +121 -121
- data/test/test_attribute_handler.rb +361 -361
- data/test/test_body.rb +87 -87
- data/test/test_caption.rb +80 -80
- data/test/test_col.rb +40 -40
- data/test/test_colgroup.rb +89 -89
- data/test/test_data.rb +77 -77
- data/test/test_foot.rb +111 -111
- data/test/test_head.rb +104 -104
- data/test/test_header.rb +77 -77
- data/test/test_html_handler.rb +37 -37
- data/test/test_row.rb +141 -141
- data/test/test_table.rb +158 -158
- data/test/test_tablesection.rb +42 -42
- data/test/test_tag_handler.rb +90 -90
- metadata +22 -22
- metadata.gz.sig +0 -0
data/certs/djberg96_pub.pem
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
|
3
3
|
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
4
|
-
|
4
|
+
MB4XDTE2MTIxMjAwMTQ1M1oXDTE3MTIxMjAwMTQ1M1owPzERMA8GA1UEAwwIZGpi
|
5
5
|
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVtTm/wETO8yKVKRPBO
|
7
|
+
VgPRvE94iEfKryOb/tQrmhGhchG2ALqdw/r54cGJvLaXeItrYJ6N8pSE/FSnN5jM
|
8
|
+
xugUhHBprPl+AsQ4E+IBy0dKwyU8XjFoVYzWvT1wnqwQdSazdgFCfQqb51QCgUIT
|
9
|
+
PGGakKlyzCb3Mbq30is8+QlRrqXt/JbpkUZbQwUqCdAulMT4oyPBk/L+48pbVX0s
|
10
|
+
4yj7YaVAqfGByAMTPXEmUS388lX+0xq8+GGir2Fuh0TpNW0ggr9BxprwqL0Mg4Oo
|
11
|
+
YhM5L1y8Plolo8mOTN3+K8I3afZ0lD0BtwniVb6g+Ut/4aBjKy2+GyFwwNOu0gSj
|
12
|
+
desCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJfg
|
13
|
+
HmQ0uDU3Z9A9hB1lQMjr5VZSMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
|
14
14
|
bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
|
15
|
-
|
16
|
-
|
17
|
-
/
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
ggEBACjRCHRP944MHIQJNCglZbDnZowybV2HxmG1uhnvRwrOjBA7CXemc+QSAL7K
|
16
|
+
7eXC4FdojVEJrnU7ZxuCmfQU+fvkEQKOnah1osG1874aPiDlwtjHclpeqcDgTUI7
|
17
|
+
A7CF+OXK8x7ksFx205ruhPHKaPYtwVG/W/J+y7Wx8yl9rvwUgRBL5cVzTBiEz+AB
|
18
|
+
NRT7yoHXXfFXjuQWN1eHunSbNds2ZTGQd64yBCujb17Xdl+F9tu4klkTga3gxP3P
|
19
|
+
y3zoX1VttxnIZBojRM/s2A7c2aubMH2SVbXMR3ccVkB9XbYKl1OvCe7q85xEHit2
|
20
|
+
Kbpico5nnyHqf7YSPmvZe8bCU94=
|
21
21
|
-----END CERTIFICATE-----
|
data/doc/attributes.rdoc
CHANGED
@@ -1,143 +1,143 @@
|
|
1
|
-
== Description
|
2
|
-
A list of attributes handled by html-table. Each of the writers has a
|
3
|
-
corresponding reader unless otherwise stated.
|
4
|
-
|
5
|
-
== Attributes
|
6
|
-
abbr=(string)
|
7
|
-
Sets the value for the abbr attribute.
|
8
|
-
|
9
|
-
align=(string)
|
10
|
-
Sets the align attribute. Valid arguments are 'left', 'center' and
|
11
|
-
'right'. An ArgumentError is raised if an invalid argument is passed.
|
12
|
-
|
13
|
-
axis=(string)
|
14
|
-
Sets the value for the axis attribute.
|
15
|
-
|
16
|
-
background=(url)
|
17
|
-
Sets the background attribute. The url must be a String or a TypeError
|
18
|
-
is raised. This is a non-standard extension.
|
19
|
-
|
20
|
-
bgcolor=(color)
|
21
|
-
Sets the color for the bgcolor attribute. Hex values should still be
|
22
|
-
quoted, e.g. "#F80000".
|
23
|
-
|
24
|
-
border=(num)
|
25
|
-
Sets the value for the border attribute.
|
26
|
-
|
27
|
-
bordercolor=(color)
|
28
|
-
Sets the color for the bordercolor attribute. This is a non-standard
|
29
|
-
extension.
|
30
|
-
|
31
|
-
bordercolordark=(color)
|
32
|
-
Sets the color for the bordercolordark attribute. This is a non-standard
|
33
|
-
extension.
|
34
|
-
|
35
|
-
bordercolorlight=(color)
|
36
|
-
Sets the color for the bordercolorlight attribute. This is a non-standard
|
37
|
-
extension.
|
38
|
-
|
39
|
-
cellpadding=(num)
|
40
|
-
Sets the value for the cellpadding attribute. Raises an ArgumentError if
|
41
|
-
num.to_i is less than 0.
|
42
|
-
|
43
|
-
cellspacing=(num)
|
44
|
-
Sets the value for the cellspacing attribute. Raises an ArgumentError if
|
45
|
-
num.to_i is less than 0.
|
46
|
-
|
47
|
-
char=(character)
|
48
|
-
Sets the value for the char attribute. An ArgumentError is raised if the
|
49
|
-
argument passed has a length greater than 1 (i.e. it may only be a char).
|
50
|
-
|
51
|
-
charoff=(value)
|
52
|
-
Sets the value for the charoff attribute.
|
53
|
-
|
54
|
-
colspan=(num)
|
55
|
-
Sets the colspan attribute.
|
56
|
-
|
57
|
-
content=(*args)
|
58
|
-
The behavior of this method varies largely based on the type of instance
|
59
|
-
that invokes it. Here are the rules for each +arg+ in +args+:
|
60
|
-
|
61
|
-
+Table+:
|
62
|
-
|
63
|
-
If +arg+ is a Row, Head, Foot, Body or ColGroup object, it is
|
64
|
-
pushed onto the table. If +arg+ is a string, one Row object with
|
65
|
-
one one Data object is pushed onto the Table. If +arg+ is an Array,
|
66
|
-
one Row object is created and each element of the array is pushed
|
67
|
-
onto that Row.
|
68
|
-
|
69
|
-
+Table::Row+:
|
70
|
-
|
71
|
-
If +arg+ is a Header or Data object, it is pushed onto the Row. If
|
72
|
-
+arg+ is a String, it is created as a single Data object. Attempts
|
73
|
-
to assign any other type will raise a TypeError.
|
74
|
-
|
75
|
-
+Table::Head, Table::Foot, Table::Body+:
|
76
|
-
|
77
|
-
Behave identically to Table::Row except that they accept Table::Row
|
78
|
-
objects as well.
|
79
|
-
|
80
|
-
+Table::ColGroup+:
|
81
|
-
|
82
|
-
Behaves identically to Table::Row except that it only accepts Col objects.
|
83
|
-
|
84
|
-
+Table::Col+:
|
85
|
-
|
86
|
-
This method is undefined for Table::Col, because they do not accept
|
87
|
-
content.
|
88
|
-
|
89
|
-
+Table::Data and Table::Header+:
|
90
|
-
|
91
|
-
Sets the text string for the Data or Header object. Arrays are join'd.
|
92
|
-
Any other type raises a TypeError.
|
93
|
-
|
94
|
-
frame=(type)
|
95
|
-
Sets the value for the frame attribute. Valid values are border, void,
|
96
|
-
above, below, hsides, lhs, rhs, vsides, and box. An ArgumentError is
|
97
|
-
raised if an invalid type is detected.
|
98
|
-
|
99
|
-
height=(num)
|
100
|
-
Sets the value for the height attribute. Raises an ArgumentError if
|
101
|
-
num.to_i is less than 0.
|
102
|
-
|
103
|
-
hspace=(num)
|
104
|
-
Sets the value for the hspace attribute. Raises an ArgumentError if
|
105
|
-
num.to_i is less than 0.
|
106
|
-
|
107
|
-
nowrap=(bool)
|
108
|
-
Sets the value for the nowrap attribute. Setting it to true means it will
|
109
|
-
be included as an attribute for the Table object. The default is false
|
110
|
-
(i.e. not included).
|
111
|
-
|
112
|
-
rowspan=(num)
|
113
|
-
Sets the value for the rowspan attribute.
|
114
|
-
|
115
|
-
rules=(edges)
|
116
|
-
Sets the value for the rules attribute. Valid values are all, groups,
|
117
|
-
rows, cols, or none. An ArgumentError is raised if an invalid edges value
|
118
|
-
is detected.
|
119
|
-
|
120
|
-
scope=(scope)
|
121
|
-
Sets the value for the scope attribute. Valid values for +scope+ are
|
122
|
-
row, col, rowgroup or colgroup. An ArgumentError is raised if an invalid
|
123
|
-
scope value is passed.
|
124
|
-
|
125
|
-
span=(num)
|
126
|
-
Sets the span attribute. If num.to_i is less than 0, and ArgumentError
|
127
|
-
is raised.
|
128
|
-
|
129
|
-
summary=(string)
|
130
|
-
Sets the value for the summary attribute.
|
131
|
-
|
132
|
-
valign=(position)
|
133
|
-
Sets the value for the valign attribute. Valid values are top, center,
|
134
|
-
bottom, and baseline. This is a non-standard extension.
|
135
|
-
|
136
|
-
vspace=(num)
|
137
|
-
Sets the value for the vspace attribute. This is a non-standard
|
138
|
-
extension.
|
139
|
-
|
140
|
-
width=(num)
|
141
|
-
Sets the value for the width attribute. If num is in 'x%' format, it
|
142
|
-
is retained as a string. If num is a Fixnum (or stringified number), an
|
143
|
-
ArgumentError is raised if num.to_i is less than 0.
|
1
|
+
== Description
|
2
|
+
A list of attributes handled by html-table. Each of the writers has a
|
3
|
+
corresponding reader unless otherwise stated.
|
4
|
+
|
5
|
+
== Attributes
|
6
|
+
abbr=(string)
|
7
|
+
Sets the value for the abbr attribute.
|
8
|
+
|
9
|
+
align=(string)
|
10
|
+
Sets the align attribute. Valid arguments are 'left', 'center' and
|
11
|
+
'right'. An ArgumentError is raised if an invalid argument is passed.
|
12
|
+
|
13
|
+
axis=(string)
|
14
|
+
Sets the value for the axis attribute.
|
15
|
+
|
16
|
+
background=(url)
|
17
|
+
Sets the background attribute. The url must be a String or a TypeError
|
18
|
+
is raised. This is a non-standard extension.
|
19
|
+
|
20
|
+
bgcolor=(color)
|
21
|
+
Sets the color for the bgcolor attribute. Hex values should still be
|
22
|
+
quoted, e.g. "#F80000".
|
23
|
+
|
24
|
+
border=(num)
|
25
|
+
Sets the value for the border attribute.
|
26
|
+
|
27
|
+
bordercolor=(color)
|
28
|
+
Sets the color for the bordercolor attribute. This is a non-standard
|
29
|
+
extension.
|
30
|
+
|
31
|
+
bordercolordark=(color)
|
32
|
+
Sets the color for the bordercolordark attribute. This is a non-standard
|
33
|
+
extension.
|
34
|
+
|
35
|
+
bordercolorlight=(color)
|
36
|
+
Sets the color for the bordercolorlight attribute. This is a non-standard
|
37
|
+
extension.
|
38
|
+
|
39
|
+
cellpadding=(num)
|
40
|
+
Sets the value for the cellpadding attribute. Raises an ArgumentError if
|
41
|
+
num.to_i is less than 0.
|
42
|
+
|
43
|
+
cellspacing=(num)
|
44
|
+
Sets the value for the cellspacing attribute. Raises an ArgumentError if
|
45
|
+
num.to_i is less than 0.
|
46
|
+
|
47
|
+
char=(character)
|
48
|
+
Sets the value for the char attribute. An ArgumentError is raised if the
|
49
|
+
argument passed has a length greater than 1 (i.e. it may only be a char).
|
50
|
+
|
51
|
+
charoff=(value)
|
52
|
+
Sets the value for the charoff attribute.
|
53
|
+
|
54
|
+
colspan=(num)
|
55
|
+
Sets the colspan attribute.
|
56
|
+
|
57
|
+
content=(*args)
|
58
|
+
The behavior of this method varies largely based on the type of instance
|
59
|
+
that invokes it. Here are the rules for each +arg+ in +args+:
|
60
|
+
|
61
|
+
+Table+:
|
62
|
+
|
63
|
+
If +arg+ is a Row, Head, Foot, Body or ColGroup object, it is
|
64
|
+
pushed onto the table. If +arg+ is a string, one Row object with
|
65
|
+
one one Data object is pushed onto the Table. If +arg+ is an Array,
|
66
|
+
one Row object is created and each element of the array is pushed
|
67
|
+
onto that Row.
|
68
|
+
|
69
|
+
+Table::Row+:
|
70
|
+
|
71
|
+
If +arg+ is a Header or Data object, it is pushed onto the Row. If
|
72
|
+
+arg+ is a String, it is created as a single Data object. Attempts
|
73
|
+
to assign any other type will raise a TypeError.
|
74
|
+
|
75
|
+
+Table::Head, Table::Foot, Table::Body+:
|
76
|
+
|
77
|
+
Behave identically to Table::Row except that they accept Table::Row
|
78
|
+
objects as well.
|
79
|
+
|
80
|
+
+Table::ColGroup+:
|
81
|
+
|
82
|
+
Behaves identically to Table::Row except that it only accepts Col objects.
|
83
|
+
|
84
|
+
+Table::Col+:
|
85
|
+
|
86
|
+
This method is undefined for Table::Col, because they do not accept
|
87
|
+
content.
|
88
|
+
|
89
|
+
+Table::Data and Table::Header+:
|
90
|
+
|
91
|
+
Sets the text string for the Data or Header object. Arrays are join'd.
|
92
|
+
Any other type raises a TypeError.
|
93
|
+
|
94
|
+
frame=(type)
|
95
|
+
Sets the value for the frame attribute. Valid values are border, void,
|
96
|
+
above, below, hsides, lhs, rhs, vsides, and box. An ArgumentError is
|
97
|
+
raised if an invalid type is detected.
|
98
|
+
|
99
|
+
height=(num)
|
100
|
+
Sets the value for the height attribute. Raises an ArgumentError if
|
101
|
+
num.to_i is less than 0.
|
102
|
+
|
103
|
+
hspace=(num)
|
104
|
+
Sets the value for the hspace attribute. Raises an ArgumentError if
|
105
|
+
num.to_i is less than 0.
|
106
|
+
|
107
|
+
nowrap=(bool)
|
108
|
+
Sets the value for the nowrap attribute. Setting it to true means it will
|
109
|
+
be included as an attribute for the Table object. The default is false
|
110
|
+
(i.e. not included).
|
111
|
+
|
112
|
+
rowspan=(num)
|
113
|
+
Sets the value for the rowspan attribute.
|
114
|
+
|
115
|
+
rules=(edges)
|
116
|
+
Sets the value for the rules attribute. Valid values are all, groups,
|
117
|
+
rows, cols, or none. An ArgumentError is raised if an invalid edges value
|
118
|
+
is detected.
|
119
|
+
|
120
|
+
scope=(scope)
|
121
|
+
Sets the value for the scope attribute. Valid values for +scope+ are
|
122
|
+
row, col, rowgroup or colgroup. An ArgumentError is raised if an invalid
|
123
|
+
scope value is passed.
|
124
|
+
|
125
|
+
span=(num)
|
126
|
+
Sets the span attribute. If num.to_i is less than 0, and ArgumentError
|
127
|
+
is raised.
|
128
|
+
|
129
|
+
summary=(string)
|
130
|
+
Sets the value for the summary attribute.
|
131
|
+
|
132
|
+
valign=(position)
|
133
|
+
Sets the value for the valign attribute. Valid values are top, center,
|
134
|
+
bottom, and baseline. This is a non-standard extension.
|
135
|
+
|
136
|
+
vspace=(num)
|
137
|
+
Sets the value for the vspace attribute. This is a non-standard
|
138
|
+
extension.
|
139
|
+
|
140
|
+
width=(num)
|
141
|
+
Sets the value for the width attribute. If num is in 'x%' format, it
|
142
|
+
is retained as a string. If num is a Fixnum (or stringified number), an
|
143
|
+
ArgumentError is raised if num.to_i is less than 0.
|
data/doc/table.rdoc
CHANGED
@@ -1,158 +1,158 @@
|
|
1
|
-
== Description
|
2
|
-
An interface for generating HTML Tables with Ruby.
|
3
|
-
|
4
|
-
== Synopsis
|
5
|
-
require "html/table"
|
6
|
-
include HTML
|
7
|
-
|
8
|
-
table = HTML::Table.new{ |t|
|
9
|
-
t.border = 1
|
10
|
-
t.bgcolor = "red"
|
11
|
-
}
|
12
|
-
|
13
|
-
table.push Table::Row.new{ |r|
|
14
|
-
r.align = "left"
|
15
|
-
r.bgcolor = "green"
|
16
|
-
r.content = ["foo","bar","baz"]
|
17
|
-
}
|
18
|
-
|
19
|
-
row = Table::Row.new{ |r|
|
20
|
-
r.align = "right"
|
21
|
-
r.bgcolor = "blue"
|
22
|
-
r.content = "hello world"
|
23
|
-
}
|
24
|
-
|
25
|
-
table[1] = row
|
26
|
-
|
27
|
-
puts table.html
|
28
|
-
|
29
|
-
#### output ####
|
30
|
-
<table border=1 bgcolor='red'>
|
31
|
-
<tr align='left' bgcolor='green'> # row 0
|
32
|
-
<td>foo</td> # column 0
|
33
|
-
<td>bar</td> # column 1
|
34
|
-
<td>baz</td> # column 2
|
35
|
-
</tr>
|
36
|
-
<tr align='right' bgcolor='blue'> # row 1
|
37
|
-
<td>hello world</td> # column 0
|
38
|
-
</tr>
|
39
|
-
</table>
|
40
|
-
|
41
|
-
See the 'examples' directory for more examples.
|
42
|
-
|
43
|
-
== Mixins
|
44
|
-
Table is a subclass of Array, and therefore mixes in Enumerable. The
|
45
|
-
push, unshift and []= methods have been modified. See below for details.
|
46
|
-
|
47
|
-
Table also mixes in the AttributeHandler module which provides methods
|
48
|
-
for adding attributes to each of the tag types. See attributes.rdoc for
|
49
|
-
more details.
|
50
|
-
|
51
|
-
== Constants
|
52
|
-
VERSION
|
53
|
-
The current version number (a String). This serves as the VERSION number
|
54
|
-
for the entire html-table package.
|
55
|
-
|
56
|
-
== Class Methods
|
57
|
-
Table.new(arg=nil)
|
58
|
-
Table.new(arg=nil){ |t| ... }
|
59
|
-
Creates a new Table instance. You can set attributes for the Table by
|
60
|
-
passing a block.
|
61
|
-
|
62
|
-
If +arg+ is supplied, it is automatically interpreted to be content. This
|
63
|
-
is a shortcut for Table.new{ |t| t.content = '...' }.
|
64
|
-
|
65
|
-
Table.global_end_tags?
|
66
|
-
Returns the value of the global_end_tags class variable. By default,
|
67
|
-
this is true.
|
68
|
-
|
69
|
-
Table.global_end_tags=(true|false)
|
70
|
-
Sets the global_end_tags class variable. This determines class-wide, for
|
71
|
-
those classes where end tags are optional, whether or not end tags are
|
72
|
-
included in the final html. Classes where end tags are not optional are
|
73
|
-
not affected.
|
74
|
-
|
75
|
-
If set to false, this overrides individual class end tags settings.
|
76
|
-
|
77
|
-
== Instance Methods
|
78
|
-
Table#[]=(index, object)
|
79
|
-
Assigns +object+ to +index+. There are restrictions to the data
|
80
|
-
types that you can assign to a Table instance. They include Caption,
|
81
|
-
ColGroup, Body, Foot, Head and Row. You cannot assign a slice (yet).
|
82
|
-
|
83
|
-
Table#configure(row_num, col_num=0){ |td_object| block }
|
84
|
-
Configures column +col_num+ at row +row_num+, using a block to set
|
85
|
-
options. If only +row_num+ is specified, then you'll be configuring
|
86
|
-
only the row. Generally speaking, that means you'll be configure a
|
87
|
-
Table::Row and not a Data or Header object.
|
88
|
-
|
89
|
-
Table#content
|
90
|
-
Returns the HTML content.
|
91
|
-
|
92
|
-
Table#content=(arg)
|
93
|
-
Adds data to the Table. The +arg+ may be a Table::Row object, an
|
94
|
-
Array of Table::Row objects, an Array of Array's, an Array of Strings,
|
95
|
-
or a single String. In the last two cases, a single Table::Row with a
|
96
|
-
single Table::Row::Data object is created, with the string as the content.
|
97
|
-
|
98
|
-
Table#html
|
99
|
-
Returns the entire HTML content for the Table Object. This is what you
|
100
|
-
want to print when you're done creating your Table.
|
101
|
-
|
102
|
-
Table#push(obj)
|
103
|
-
Pushes +obj+ onto the Table, where +obj+ must be a Row, Caption,
|
104
|
-
ColGroup, Body, Foot or Head object. Also note that the Caption and Head
|
105
|
-
objects will automatically put themselves at row 0 (or possibly 1, in the
|
106
|
-
case of a Head object where a Caption already exists).
|
107
|
-
|
108
|
-
Table#unshift(obj)
|
109
|
-
Unshifts +obj+ onto the Table. The same rules apply to unshift as
|
110
|
-
they do to push.
|
111
|
-
|
112
|
-
== Notes
|
113
|
-
A Table consists of Table::Row, Table::Caption, Table::ColGroup,
|
114
|
-
Table::Body, Table::Foot, Table::Head and Table::Row objects. Table::Row
|
115
|
-
objects in turn consist of Table::Row::Data and Table::Row::Header
|
116
|
-
objects. Table::ColGroup objects consist of Table::ColGroup::Col
|
117
|
-
objects. Table::Head, Table::Body and Table::Foot objects consist
|
118
|
-
of Table::Row objects.
|
119
|
-
|
120
|
-
String attributes are quoted. Numeric attributes are not.
|
121
|
-
|
122
|
-
Some attributes have type checking. Some check for valid arguments. In
|
123
|
-
the latter case, it is case-insensitive. See the documentation on
|
124
|
-
specific methods for more details.
|
125
|
-
|
126
|
-
Using a non-standard extension (e.g. "background") will send a warning to
|
127
|
-
STDERR in $VERBOSE (-w) mode.
|
128
|
-
|
129
|
-
== Known Bugs
|
130
|
-
None that I'm aware of. Please report bugs on the project page at
|
131
|
-
http://www.rubyforge.org/projects/shards.
|
132
|
-
|
133
|
-
== Future Plans
|
134
|
-
Allow standard html tags to be added to elements as appropriate, such
|
135
|
-
as <B>, <I>, etc.
|
136
|
-
|
137
|
-
CSS support.
|
138
|
-
|
139
|
-
== Acknowledgements
|
140
|
-
Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
|
141
|
-
Holden Glova and Culley Harrelson for API suggestions and comments.
|
142
|
-
|
143
|
-
== License
|
144
|
-
Ruby's
|
145
|
-
|
146
|
-
== Copyright
|
147
|
-
(C) 2003-2008 Daniel J. Berger
|
148
|
-
All Rights Reserved
|
149
|
-
|
150
|
-
== Warranty
|
151
|
-
This package is provided "as is" and without any express or
|
152
|
-
implied warranties, including, without limitation, the implied
|
153
|
-
warranties of merchantability and fitness for a particular purpose.
|
154
|
-
|
155
|
-
== Author
|
156
|
-
Daniel J. Berger
|
157
|
-
djberg96 at nospam at gmail dot com
|
158
|
-
imperator on IRC (irc.freenode.net)
|
1
|
+
== Description
|
2
|
+
An interface for generating HTML Tables with Ruby.
|
3
|
+
|
4
|
+
== Synopsis
|
5
|
+
require "html/table"
|
6
|
+
include HTML
|
7
|
+
|
8
|
+
table = HTML::Table.new{ |t|
|
9
|
+
t.border = 1
|
10
|
+
t.bgcolor = "red"
|
11
|
+
}
|
12
|
+
|
13
|
+
table.push Table::Row.new{ |r|
|
14
|
+
r.align = "left"
|
15
|
+
r.bgcolor = "green"
|
16
|
+
r.content = ["foo","bar","baz"]
|
17
|
+
}
|
18
|
+
|
19
|
+
row = Table::Row.new{ |r|
|
20
|
+
r.align = "right"
|
21
|
+
r.bgcolor = "blue"
|
22
|
+
r.content = "hello world"
|
23
|
+
}
|
24
|
+
|
25
|
+
table[1] = row
|
26
|
+
|
27
|
+
puts table.html
|
28
|
+
|
29
|
+
#### output ####
|
30
|
+
<table border=1 bgcolor='red'>
|
31
|
+
<tr align='left' bgcolor='green'> # row 0
|
32
|
+
<td>foo</td> # column 0
|
33
|
+
<td>bar</td> # column 1
|
34
|
+
<td>baz</td> # column 2
|
35
|
+
</tr>
|
36
|
+
<tr align='right' bgcolor='blue'> # row 1
|
37
|
+
<td>hello world</td> # column 0
|
38
|
+
</tr>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
See the 'examples' directory for more examples.
|
42
|
+
|
43
|
+
== Mixins
|
44
|
+
Table is a subclass of Array, and therefore mixes in Enumerable. The
|
45
|
+
push, unshift and []= methods have been modified. See below for details.
|
46
|
+
|
47
|
+
Table also mixes in the AttributeHandler module which provides methods
|
48
|
+
for adding attributes to each of the tag types. See attributes.rdoc for
|
49
|
+
more details.
|
50
|
+
|
51
|
+
== Constants
|
52
|
+
VERSION
|
53
|
+
The current version number (a String). This serves as the VERSION number
|
54
|
+
for the entire html-table package.
|
55
|
+
|
56
|
+
== Class Methods
|
57
|
+
Table.new(arg=nil)
|
58
|
+
Table.new(arg=nil){ |t| ... }
|
59
|
+
Creates a new Table instance. You can set attributes for the Table by
|
60
|
+
passing a block.
|
61
|
+
|
62
|
+
If +arg+ is supplied, it is automatically interpreted to be content. This
|
63
|
+
is a shortcut for Table.new{ |t| t.content = '...' }.
|
64
|
+
|
65
|
+
Table.global_end_tags?
|
66
|
+
Returns the value of the global_end_tags class variable. By default,
|
67
|
+
this is true.
|
68
|
+
|
69
|
+
Table.global_end_tags=(true|false)
|
70
|
+
Sets the global_end_tags class variable. This determines class-wide, for
|
71
|
+
those classes where end tags are optional, whether or not end tags are
|
72
|
+
included in the final html. Classes where end tags are not optional are
|
73
|
+
not affected.
|
74
|
+
|
75
|
+
If set to false, this overrides individual class end tags settings.
|
76
|
+
|
77
|
+
== Instance Methods
|
78
|
+
Table#[]=(index, object)
|
79
|
+
Assigns +object+ to +index+. There are restrictions to the data
|
80
|
+
types that you can assign to a Table instance. They include Caption,
|
81
|
+
ColGroup, Body, Foot, Head and Row. You cannot assign a slice (yet).
|
82
|
+
|
83
|
+
Table#configure(row_num, col_num=0){ |td_object| block }
|
84
|
+
Configures column +col_num+ at row +row_num+, using a block to set
|
85
|
+
options. If only +row_num+ is specified, then you'll be configuring
|
86
|
+
only the row. Generally speaking, that means you'll be configure a
|
87
|
+
Table::Row and not a Data or Header object.
|
88
|
+
|
89
|
+
Table#content
|
90
|
+
Returns the HTML content.
|
91
|
+
|
92
|
+
Table#content=(arg)
|
93
|
+
Adds data to the Table. The +arg+ may be a Table::Row object, an
|
94
|
+
Array of Table::Row objects, an Array of Array's, an Array of Strings,
|
95
|
+
or a single String. In the last two cases, a single Table::Row with a
|
96
|
+
single Table::Row::Data object is created, with the string as the content.
|
97
|
+
|
98
|
+
Table#html
|
99
|
+
Returns the entire HTML content for the Table Object. This is what you
|
100
|
+
want to print when you're done creating your Table.
|
101
|
+
|
102
|
+
Table#push(obj)
|
103
|
+
Pushes +obj+ onto the Table, where +obj+ must be a Row, Caption,
|
104
|
+
ColGroup, Body, Foot or Head object. Also note that the Caption and Head
|
105
|
+
objects will automatically put themselves at row 0 (or possibly 1, in the
|
106
|
+
case of a Head object where a Caption already exists).
|
107
|
+
|
108
|
+
Table#unshift(obj)
|
109
|
+
Unshifts +obj+ onto the Table. The same rules apply to unshift as
|
110
|
+
they do to push.
|
111
|
+
|
112
|
+
== Notes
|
113
|
+
A Table consists of Table::Row, Table::Caption, Table::ColGroup,
|
114
|
+
Table::Body, Table::Foot, Table::Head and Table::Row objects. Table::Row
|
115
|
+
objects in turn consist of Table::Row::Data and Table::Row::Header
|
116
|
+
objects. Table::ColGroup objects consist of Table::ColGroup::Col
|
117
|
+
objects. Table::Head, Table::Body and Table::Foot objects consist
|
118
|
+
of Table::Row objects.
|
119
|
+
|
120
|
+
String attributes are quoted. Numeric attributes are not.
|
121
|
+
|
122
|
+
Some attributes have type checking. Some check for valid arguments. In
|
123
|
+
the latter case, it is case-insensitive. See the documentation on
|
124
|
+
specific methods for more details.
|
125
|
+
|
126
|
+
Using a non-standard extension (e.g. "background") will send a warning to
|
127
|
+
STDERR in $VERBOSE (-w) mode.
|
128
|
+
|
129
|
+
== Known Bugs
|
130
|
+
None that I'm aware of. Please report bugs on the project page at
|
131
|
+
http://www.rubyforge.org/projects/shards.
|
132
|
+
|
133
|
+
== Future Plans
|
134
|
+
Allow standard html tags to be added to elements as appropriate, such
|
135
|
+
as <B>, <I>, etc.
|
136
|
+
|
137
|
+
CSS support.
|
138
|
+
|
139
|
+
== Acknowledgements
|
140
|
+
Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
|
141
|
+
Holden Glova and Culley Harrelson for API suggestions and comments.
|
142
|
+
|
143
|
+
== License
|
144
|
+
Ruby's
|
145
|
+
|
146
|
+
== Copyright
|
147
|
+
(C) 2003-2008 Daniel J. Berger
|
148
|
+
All Rights Reserved
|
149
|
+
|
150
|
+
== Warranty
|
151
|
+
This package is provided "as is" and without any express or
|
152
|
+
implied warranties, including, without limitation, the implied
|
153
|
+
warranties of merchantability and fitness for a particular purpose.
|
154
|
+
|
155
|
+
== Author
|
156
|
+
Daniel J. Berger
|
157
|
+
djberg96 at nospam at gmail dot com
|
158
|
+
imperator on IRC (irc.freenode.net)
|