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/doc/attributes.md ADDED
@@ -0,0 +1,160 @@
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
+
8
+ Sets the value for the abbr attribute.
9
+
10
+ `align=(string)`
11
+
12
+ Sets the align attribute. Valid arguments are 'left', 'center' and
13
+ 'right'. An ArgumentError is raised if an invalid argument is passed.
14
+
15
+ `axis=(string)`
16
+
17
+ Sets the value for the axis attribute.
18
+
19
+ `background=(url)`
20
+
21
+ Sets the background attribute. The url must be a String or a TypeError
22
+ is raised. This is a non-standard extension.
23
+
24
+ `bgcolor=(color)`
25
+
26
+ Sets the color for the bgcolor attribute. Hex values should still be
27
+ quoted, e.g. "#F80000".
28
+
29
+ `border=(num)`
30
+
31
+ Sets the value for the border attribute.
32
+
33
+ `bordercolor=(color)`
34
+
35
+ Sets the color for the bordercolor attribute. This is a non-standard extension.
36
+
37
+ `bordercolordark=(color)`
38
+
39
+ Sets the color for the bordercolordark attribute. This is a non-standard extension.
40
+
41
+ `bordercolorlight=(color)`
42
+
43
+ Sets the color for the bordercolorlight attribute. This is a non-standard extension.
44
+
45
+ `cellpadding=(num)`
46
+
47
+ Sets the value for the cellpadding attribute. Raises an ArgumentError if num.to_i is less than 0.
48
+
49
+ `cellspacing=(num)`
50
+
51
+ Sets the value for the cellspacing attribute. Raises an ArgumentError if num.to_i is less than 0.
52
+
53
+ `char=(character)`
54
+
55
+ Sets the value for the char attribute. An ArgumentError is raised if the
56
+ argument passed has a length greater than 1 (i.e. it may only be a char).
57
+
58
+ `charoff=(value)`
59
+
60
+ Sets the value for the charoff attribute.
61
+
62
+ `colspan=(num)`
63
+
64
+ Sets the colspan attribute.
65
+
66
+ `content=(*args)`
67
+
68
+ The behavior of this method varies largely based on the type of instance
69
+ that invokes it. Here are the rules for each argument in `args`:
70
+
71
+ * `Table`:
72
+
73
+ If `arg` is a `Row`, `Head`, `Foot`, `Body` or `ColGroup` object, it is
74
+ pushed onto the table. If `arg` is a string, one `Row` object with
75
+ one one `Data` object is pushed onto the `Table`. If `arg` is an `Array`,
76
+ then one `Row` object is created and each element of the array is pushed
77
+ onto that Row.
78
+
79
+ * `Table::Row`:
80
+
81
+ If `arg` is a `Header` or `Data` object, it is pushed onto the `Row`. If
82
+ `arg` is a `String`, it is created as a single `Data` object. Any attempt
83
+ to assign any other type will raise a `TypeError`.
84
+
85
+ * `Table::Head`, `Table::Foot`, `Table::Body`:
86
+
87
+ Behave identically to `Table::Row` except that they accept Table::Row objects as well.
88
+
89
+ * `Table::ColGroup`:
90
+
91
+ Behaves identically to Table::Row except that it only accepts Col objects.
92
+
93
+ * `Table::Col`:
94
+
95
+ This method is undefined for Table::Col, because they do not accept content.
96
+
97
+ * `Table::Data and Table::Header`:
98
+
99
+ Sets the text string for the `Data` or `Header` object. Arrays are join'd.
100
+ Any other type raises a `TypeError`.
101
+
102
+ `frame=(type)`
103
+
104
+ Sets the value for the frame attribute. Valid values are border, void,
105
+ above, below, hsides, lhs, rhs, vsides, and box. An ArgumentError is
106
+ raised if an invalid type is detected.
107
+
108
+ `height=(num)`
109
+
110
+ Sets the value for the height attribute. Raises an ArgumentError if
111
+ num.to_i is less than 0.
112
+
113
+ `hspace=(num)`
114
+
115
+ Sets the value for the hspace attribute. Raises an ArgumentError if
116
+ num.to_i is less than 0.
117
+
118
+ `nowrap=(bool)`
119
+
120
+ Sets the value for the nowrap attribute. Setting it to true means it will be
121
+ included as an attribute for the Table object. The default is false (i.e. not included).
122
+
123
+ `rowspan=(num)`
124
+
125
+ Sets the value for the rowspan attribute.
126
+
127
+ `rules=(edges)`
128
+
129
+ Sets the value for the rules attribute. Valid values are "all", "groups",
130
+ "rows", "cols", or "none". An `ArgumentError` is raised if an invalid edges value
131
+ is detected.
132
+
133
+ `scope=(scope)`
134
+
135
+ Sets the value for the scope attribute. Valid values for +scope+ are
136
+ row, col, rowgroup or colgroup. An ArgumentError is raised if an invalid
137
+ scope value is passed.
138
+
139
+ `span=(num)`
140
+
141
+ Sets the span attribute. If num.to_i is less than 0, and ArgumentError is raised.
142
+
143
+ `summary=(string)`
144
+
145
+ Sets the value for the summary attribute.
146
+
147
+ `valign=(position)`
148
+
149
+ Sets the value for the valign attribute. Valid values are top, center,
150
+ bottom, and baseline. This is a non-standard extension.
151
+
152
+ `vspace=(num)`
153
+
154
+ Sets the value for the vspace attribute. This is a non-standard extension.
155
+
156
+ `width=(num)`
157
+
158
+ Sets the value for the width attribute. If num is in 'x%' format, it
159
+ is retained as a string. If num is a Fixnum (or stringified number), an
160
+ ArgumentError is raised if num.to_i is less than 0.
data/doc/table.md ADDED
@@ -0,0 +1,173 @@
1
+ ## Description
2
+ An interface for generating HTML Tables with Ruby.
3
+
4
+ ## Synopsis
5
+ ```ruby
6
+ require "html/table"
7
+ include HTML
8
+
9
+ table = HTML::Table.new{ |t|
10
+ t.border = 1
11
+ t.bgcolor = "red"
12
+ }
13
+
14
+ table.push Table::Row.new{ |r|
15
+ r.align = "left"
16
+ r.bgcolor = "green"
17
+ r.content = ["foo","bar","baz"]
18
+ }
19
+
20
+ row = Table::Row.new{ |r|
21
+ r.align = "right"
22
+ r.bgcolor = "blue"
23
+ r.content = "hello world"
24
+ }
25
+
26
+ table[1] = row
27
+
28
+ puts table.html
29
+
30
+ #### output ####
31
+ <table border=1 bgcolor='red'>
32
+ <tr align='left' bgcolor='green'> # row 0
33
+ <td>foo</td> # column 0
34
+ <td>bar</td> # column 1
35
+ <td>baz</td> # column 2
36
+ </tr>
37
+ <tr align='right' bgcolor='blue'> # row 1
38
+ <td>hello world</td> # column 0
39
+ </tr>
40
+ </table>
41
+ ```
42
+
43
+ See the 'examples' directory for more examples.
44
+
45
+ ## Mixins
46
+ `Table` is a subclass of `Array`, and therefore mixes in `Enumerable`. The
47
+ `push`, `unshift` and `[]=` methods have been modified. See below for details.
48
+
49
+ Table also mixes in the `AttributeHandler` module which provides methods
50
+ for adding attributes to each of the tag types. See attributes.md for
51
+ more details.
52
+
53
+ ## Constants
54
+ `VERSION`
55
+
56
+ The current version number (a String). This serves as the VERSION number
57
+ for the entire html-table package.
58
+
59
+ ## Class Methods
60
+ ```
61
+ Table.new(arg=nil)
62
+ Table.new(arg=nil){ |t| ... }
63
+ ```
64
+
65
+ Creates a new Table instance. You can set attributes for the Table by
66
+ passing a block.
67
+
68
+ If `arg` is supplied, it is automatically interpreted to be content. This
69
+ is a shortcut for `Table.new{ |t| t.content = '...' }`.
70
+
71
+ `Table.global_end_tags?`
72
+
73
+ Returns the value of the `global_end_tags` class variable. By default,
74
+ this is true.
75
+
76
+ `Table.global_end_tags=(true|false)`
77
+
78
+ Sets the `global_end_tags` class variable. This determines class-wide, for
79
+ those classes where end tags are optional, whether or not end tags are
80
+ included in the final html. Classes where end tags are not optional are
81
+ not affected.
82
+
83
+ If set to false, this overrides individual class end tags settings.
84
+
85
+ ## Instance Methods
86
+ `Table#[]=(index, object)`
87
+
88
+ Assigns `object` to `index`. There are restrictions to the data
89
+ types that you can assign to a Table instance. They include `Caption`,
90
+ `ColGroup`, `Body`, `Foot`, `Head` and `Row`. You cannot assign a slice (yet).
91
+
92
+ `Table#configure(row_num, col_num=0){ |td_object| block }`
93
+
94
+ Configures column `col_num` at row `row_num`, using a block to set
95
+ options. If only `row_num` is specified, then you'll be configuring
96
+ only the row. Generally speaking, that means you'll be configure a
97
+ Table::Row and not a Data or Header object.
98
+
99
+ `Table#content`
100
+
101
+ Returns the HTML content.
102
+
103
+ `Table#content=(arg)`
104
+
105
+ Adds data to the Table. The `arg` may be a Table::Row object, an
106
+ Array of Table::Row objects, an Array of Array's, an Array of Strings,
107
+ or a single String. In the last two cases, a single Table::Row with a
108
+ single Table::Row::Data object is created, with the string as the content.
109
+
110
+ `Table#html`
111
+
112
+ Returns the entire HTML content for the Table Object. This is what you
113
+ want to print when you're done creating your Table.
114
+
115
+ `Table#push(obj)`
116
+
117
+ Pushes `obj` onto the Table, where `obj` must be a Row, Caption,
118
+ ColGroup, Body, Foot or Head object. Also note that the Caption and Head
119
+ objects will automatically put themselves at row 0 (or possibly 1, in the
120
+ case of a Head object where a Caption already exists).
121
+
122
+ `Table#unshift(obj)`
123
+
124
+ Unshifts `obj` onto the Table. The same rules apply to `unshift` as
125
+ they do to `push`.
126
+
127
+ ## Notes
128
+ A Table consists of Table::Row, Table::Caption, Table::ColGroup,
129
+ Table::Body, Table::Foot, Table::Head and Table::Row objects.
130
+
131
+ Table::Row objects in turn consist of Table::Row::Data and Table::Row::Header objects.
132
+
133
+ Table::ColGroup objects consist of Table::ColGroup::Col objects.
134
+
135
+ Table::Head, Table::Body and Table::Foot objects consist of Table::Row objects.
136
+
137
+ String attributes are quoted. Numeric attributes are not.
138
+
139
+ Some attributes have type checking. Some check for valid arguments. In
140
+ the latter case, it is case-insensitive. See the documentation on
141
+ specific methods for more details.
142
+
143
+ Using a non-standard extension (e.g. "background") will send a warning to
144
+ STDERR in `$VERBOSE` (-w) mode.
145
+
146
+ ## Known Bugs
147
+ None that I'm aware of. Please report bugs on the project page at
148
+ https://github.com/djberg96/html-table
149
+
150
+ ## Future Plans
151
+ Allow standard html tags to be added to elements as appropriate, such
152
+ as `<B>`, `<I>`, etc.
153
+
154
+ CSS support.
155
+
156
+ ## Acknowledgements
157
+ Anthony Peacock, for giving me ideas with his HTML::Table Perl module.
158
+ Holden Glova and Culley Harrelson for API suggestions and comments.
159
+
160
+ ## License
161
+ Apache-2.0
162
+
163
+ ## Copyright
164
+ (C) 2003-2021 Daniel J. Berger
165
+ All Rights Reserved
166
+
167
+ ## Warranty
168
+ This package is provided "as is" and without any express or
169
+ implied warranties, including, without limitation, the implied
170
+ warranties of merchantability and fitness for a particular purpose.
171
+
172
+ ## Author
173
+ Daniel J. Berger
data/doc/table_body.md ADDED
@@ -0,0 +1,9 @@
1
+ ## Description
2
+ A Table::Body object represents a single `<TBODY></TBODY>` instance for an HTML Table.
3
+
4
+ ## Notes
5
+ In virtually every respect the Table::Body class is identical to
6
+ the Table or Table::Row class. Unlike Table::Foot or Table::Head, there
7
+ can be more than one instance (i.e. it's not a singleton class).
8
+
9
+ A Table::Body contains Table::Row objects.
@@ -0,0 +1,10 @@
1
+ ## Description
2
+ A Table::Caption object represents a single `<CAPTION></CAPTION>` instance
3
+ for an HTML Table.
4
+
5
+ ## Notes
6
+ The Table::Caption class is virtually identical to the Table::Row::Data
7
+ class. There is one important behavioral difference, however. First,
8
+ there can only be one Table::Caption. If you attempt to add a second one,
9
+ it will merely overwrite the existing one. Second, a Table::Caption is
10
+ always bumped to index 0.
@@ -0,0 +1,8 @@
1
+ ## Description
2
+ A Table::ColGroup object represents a single `<COLGROUP></COLGROUP>`
3
+ instance for an HTML Table.
4
+
5
+ ## Notes
6
+ In virtually every respect the Table::ColGroup class is identical to the
7
+ Table::Row class. The only difference, beyond the begin and end tags, is
8
+ that a ColGroup may only contain instances of the Col class.
@@ -0,0 +1,7 @@
1
+ ## Description
2
+ A Table::ColGroup::Col object represents a single `<COL>` instance for an HTML Table.
3
+
4
+ ## Notes
5
+ In virtually every respect the Table::ColGroup::Col class is identical to
6
+ the Table::Row::Data class. The only differences are that a Table::ColGroup::Col
7
+ instance does not contain any content, nor does it include an end tag.
@@ -0,0 +1,17 @@
1
+ ## Description
2
+ A Table::Content is a wrapper for content used for Table::Row::Data and
3
+ Table::Row::Header objects. Although it can be instantiated directly, in
4
+ practice it is autogenerated for you.
5
+
6
+ ## Notes
7
+ Table::Content is a subclass of String and was mostly created in order
8
+ to support a DSL style syntax as well as physical tags.
9
+
10
+ ## Synopsis
11
+ ```ruby
12
+ content = Table::Content.new('my content') do
13
+ bold true
14
+ italics true
15
+ underline true
16
+ end
17
+ ```
data/doc/table_foot.md ADDED
@@ -0,0 +1,8 @@
1
+ ## Description
2
+ A Table::Foot object represents a single `<TFOOT></TFOOT>` instance for an HTML Table.
3
+
4
+ ## Notes
5
+ In virtually every respect the Table::Foot class is identical to the
6
+ Table or Table::Row class. There is one significant difference. The
7
+ Table::Foot class is a singleton. There can be only one Table::Foot
8
+ instance per table.
data/doc/table_head.md ADDED
@@ -0,0 +1,10 @@
1
+ ## Description
2
+ A Table::Head object represents a single `<THEAD></THEAD>` instance for an HTML Table.
3
+
4
+ ## Notes
5
+ In virtually every respect the Table::Head class is identical to
6
+ the Table or Table::Row class. There are two significant differences.
7
+ First, the Table::Head class is a singleton. There can be only one
8
+ Table::Head instance per table. Second, if an instance of Table::Head
9
+ is added to a table, it will be automatically be put at index 0 (or 1
10
+ if a Table::Caption exists).
data/doc/table_row.md ADDED
@@ -0,0 +1,114 @@
1
+ ## Description
2
+ A Table::Row object represents a single <TR></TR> instance for an HTML
3
+ Table. Although it is nested under Table, it is not a subclass of Table.
4
+ It is, however, a subclass of Array.
5
+
6
+ ## Synopsis
7
+ ```ruby
8
+ require "html/table"
9
+ include HTML
10
+
11
+ table = HTML::Table.new
12
+
13
+ row1 = Table::Row.new{ |r|
14
+ r.align = "left"
15
+ r.bgcolor = "green"
16
+ r.content = ["foo","bar","baz"]
17
+ }
18
+
19
+ row2 = Table::Row.new{ |r|
20
+ r.align = "right"
21
+ r.bgcolor = "blue"
22
+ r.content = "hello world"
23
+ }
24
+
25
+ table.push row1, row2
26
+
27
+ row1.content = "foofoo"
28
+ row1.configure(3){ |d| d.bgcolor = "pink" }
29
+
30
+ row1.push Table::Row::Header.new{ |h|
31
+ h.colspan = 2
32
+ h.content = "This is a table header"
33
+ }
34
+
35
+ row2.push Table::Row::Header.new{ |h|
36
+ h.colspan = 2
37
+ h.content = "This is also a table header"
38
+ }
39
+
40
+ puts table.html
41
+ #### output ####
42
+ ```
43
+ ```html
44
+ <table>
45
+ <tr align='left' bgcolor='green'>
46
+ <td>foo</td>
47
+ <td>bar</td>
48
+ <td>baz</td>
49
+ <td bgcolor='pink'>foofoo</td>
50
+ <th colspan=2>This is a table header</th>
51
+ </tr>
52
+ <tr align='right' bgcolor='blue'>
53
+ <td>hello world</td>
54
+ <th colspan=2>This is also a table header</th>
55
+ </tr>
56
+ </table>
57
+ ```
58
+
59
+ See the 'examples' directory for more examples.
60
+
61
+ ## Mixins
62
+ Table::Row is a subclass of Array and therefore mixes in Enumerable. It
63
+ also mixes in Attribute_Handler.
64
+
65
+ ## Class Methods
66
+ ```
67
+ Table::Row.new(arg=nil)
68
+ Table::Row.new(arg=nil){ |t| ... }
69
+ ```
70
+
71
+ Creates a new table. You can set attributes for the TableRow by passing a block.
72
+
73
+ If `arg` is supplied, it is automatically interpreted to be content.
74
+ This is a shortcut for Table::Row.new{ |r| r.content = '...' }.
75
+
76
+ ## Instance Methods
77
+ `Table::Row#[]=(index, obj)`
78
+
79
+ Assigns `obj` to index. The `obj` must be a Table::Row::Header or
80
+ Table::Row::Data object, or a TypeError is raised.
81
+
82
+ Table::Row#content
83
+ Returns the HTML content of the TableRow instance, i.e. the stuff between
84
+ the `<TR>` and `</TR>` tags.
85
+
86
+ `Table::Row#content=(args)`
87
+
88
+ Because a Table::Row doesn't store any of its own content, the arguments
89
+ to this method must be a Table::Row::Data object, a Table::Row::Header
90
+ object, or a String (or an array of any of these). In the latter case,
91
+ a single Table::Row::Data object is created for each string.
92
+
93
+ `Table::Row#html`
94
+
95
+ Returns the entire HTML content of the TableRow instance.
96
+
97
+ `Table::Row#push(obj)`
98
+
99
+ Pushes `obj` onto the Table::Row. The +obj+ must be a Table::Row::Data
100
+ or Table::Row::Header object, or a TypeError is raised.
101
+
102
+ `Table::Row#unshift(obj)`
103
+
104
+ Unshifts +obj+ onto the Table::Row. The same rules for push apply
105
+ to unshift as well.
106
+
107
+ ## Notes
108
+ String attributes are quoted. Numeric attributes are not.
109
+
110
+ Some attributes have type checking. Some check for valid arguments. In
111
+ the latter case, it is case-insensitive.
112
+
113
+ Using a non-standard extension (e.g. "background") will send a warning to
114
+ STDERR in $VERBOSE (-w) mode.
@@ -0,0 +1,100 @@
1
+ ## Description
2
+ A Table::Row::Data object represents a single <TD></TD> instance for an HTML
3
+ Table. For purposes of html-table, it also represents a "column".
4
+
5
+ ## Synopsis
6
+ ```ruby
7
+ require "html/table"
8
+ require HTML
9
+
10
+ Table::Row.end_tags = false
11
+ Table::Row::Data.end_tags = false
12
+
13
+ table = Table.new{ |t| t.border = 1 }
14
+ row = Table::Row.new
15
+
16
+ col1 = Table::Row::Data.new{ |d|
17
+ d.abbr = "test"
18
+ d.align = "right"
19
+ d.content = "hello world"
20
+ }
21
+
22
+ col2 = Table::Row::Data.new{ |d|
23
+ d.align = "center"
24
+ d.content = "Matz rules!"
25
+ }
26
+
27
+ col3 = Table::Row::Data.new{ |d|
28
+ d.align = "left"
29
+ d.content = "Foo!"
30
+ }
31
+
32
+ row.push col1, col2, col3
33
+
34
+ puts table.html
35
+ ```
36
+
37
+ output:
38
+
39
+ ```html
40
+ <table border=1>
41
+ <tr>
42
+ <td abbr='test' align='right'>hello world
43
+ <td align='center'>Matz rules!
44
+ <td align='left'>Foo!
45
+ </table>
46
+ ```
47
+
48
+ See the 'examples' directory under 'doc' for more examples.
49
+
50
+ ## Mixins
51
+ Table::Row::Data mixes in Attribute_Handler.
52
+
53
+ ## Class Methods
54
+ ```
55
+ Table::Row::Data.new(arg=nil)
56
+ Table::Row::Data.new(arg=nil){ |t| ... }
57
+ ```
58
+ Creates a new table. You can set attributes for the Table::Row::Data by passing a block.
59
+
60
+ If `arg` is supplied, it is automatically interpreted to be content.
61
+ This is a shortcut for Table::Row::Data.new{ |d| d.content = '...' }.
62
+
63
+ `Table::Row::Data.end_tags`
64
+
65
+ Returns true or false to indicate whether end tags are included or not.
66
+
67
+ `Table::Row::Data.end_tags=(bool)`
68
+
69
+ Sets whether or not end tags are included in the html.
70
+
71
+ `Table::Row::Data.indent_level`
72
+ Returns the current number of spaces that `<TD>` tags are indented. The default is 6.
73
+
74
+ `Table::Row::Data.indent_level=(num)`
75
+
76
+ Sets the number of spaces that `<TD>` tags are indented.
77
+
78
+ ## Instance Methods
79
+ TableData#content
80
+
81
+ Returns the content of the TableData object, i.e. the stuff between `<TD>` and `</TD>`.
82
+
83
+ Table::Row::Data#content=(string)
84
+
85
+ Sets the content for the TableData object, i.e. the stuff between `<TD>` and `</TD>`.
86
+
87
+ Table::Row::Data#html
88
+
89
+ Returns all html content for the TableData instance.
90
+
91
+ ## Notes
92
+ The end tags for Table::Row::Data objects are are the same line as the begin tags.
93
+
94
+ String attributes are quoted. Numeric attributes are not.
95
+
96
+ Some attributes have type checking. Some check for valid arguments. In
97
+ the latter case, it is case-insensitive.
98
+
99
+ Using a non-standard extension (e.g. "background") will send a warning to
100
+ STDERR in $VERBOSE (-w) mode.
@@ -0,0 +1,6 @@
1
+ ## Description
2
+ A Table::Row::Header object represents a single `<TH></TH>` instance for an HTML Table.
3
+
4
+ ## Notes
5
+ The Table::Row::Header class is identical in every way to the
6
+ Table::Row::Data class, except for the begin and end tags.
data/examples/simple1.rb CHANGED
@@ -9,13 +9,15 @@ require 'html/table'
9
9
  include HTML
10
10
 
11
11
  table = Table.new{ |t|
12
- t.content = [
13
- %w/foo bar baz/,
14
- %w/1 2 3/,
15
- %w/hello world/
16
- ]
12
+ t.content = [
13
+ %w[foo bar baz],
14
+ %w[1 2 3],
15
+ %w[hello world]
16
+ ]
17
17
  }
18
18
 
19
+ #Table.global_end_tags = false
20
+
19
21
  puts table.html
20
22
 
21
23
  =begin