html-table 1.3.3 → 1.3.4

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.
@@ -1,72 +1,72 @@
1
- ##############################################################################
2
- # intermediate1.rb
3
- #
4
- # A slightly more advanced HTML Table. This time we'll add some attributes,
5
- # add a few rows both implicitly and explicitly, then configure it
6
- # after-the-fact.
7
- #
8
- # You can run this via the "example:intermediate1" rake task.
9
- ##############################################################################
10
- require 'html/table'
11
- include HTML
12
-
13
- # Create a table, add two rows implicitly
14
- table = Table.new{ |t|
15
- t.border = 1
16
- t.align = "left"
17
- t.content = [
18
- ["foo","bar","baz"],
19
- [1,2]
20
- ]
21
- }
22
-
23
- # Create a Table::Row object with one Data object added implicitly
24
- row1 = Table::Row.new{ |r|
25
- r.bgcolor = "red"
26
- r.nowrap = true
27
- r.content = "test"
28
- }
29
-
30
- # Create a Table::Row object, add a Data object explicitly (with some
31
- # configuration to boot)
32
- row2 = Table::Row.new{ |r|
33
- r.bgcolor = "blue"
34
- r.align = "right"
35
- r.content = Table::Row::Data.new{ |d|
36
- d.content = "hello world!"
37
- d.abbr = "test abbr"
38
- }
39
- }
40
-
41
- # Add the rows explicitly to the table
42
- table.push row1, row2
43
-
44
- # Let's configure the row that contains "foo","bar","baz"
45
- # Remember, row and column counts start at 0, not 1
46
- table.configure(0){ |r|
47
- r.bgcolor = "green"
48
- r.align = "right"
49
- }
50
-
51
- puts table.html
52
-
53
- =begin
54
- ### OUTPUT ###
55
- <table border=1 align='left'>
56
- <tr bgcolor='green' align='right'>
57
- <td>foo</td>
58
- <td>bar</td>
59
- <td>baz</td>
60
- </tr>
61
- <tr>
62
- <td>1</td>
63
- <td>2</td>
64
- </tr>
65
- <tr bgcolor='red' nowrap>
66
- <td>test</td>
67
- </tr>
68
- <tr bgcolor='blue' align='right'>
69
- <td abbr='test abbr'>hello world!</td>
70
- </tr>
71
- </table>
72
- =end
1
+ ##############################################################################
2
+ # intermediate1.rb
3
+ #
4
+ # A slightly more advanced HTML Table. This time we'll add some attributes,
5
+ # add a few rows both implicitly and explicitly, then configure it
6
+ # after-the-fact.
7
+ #
8
+ # You can run this via the "example:intermediate1" rake task.
9
+ ##############################################################################
10
+ require 'html/table'
11
+ include HTML
12
+
13
+ # Create a table, add two rows implicitly
14
+ table = Table.new{ |t|
15
+ t.border = 1
16
+ t.align = "left"
17
+ t.content = [
18
+ ["foo","bar","baz"],
19
+ [1,2]
20
+ ]
21
+ }
22
+
23
+ # Create a Table::Row object with one Data object added implicitly
24
+ row1 = Table::Row.new{ |r|
25
+ r.bgcolor = "red"
26
+ r.nowrap = true
27
+ r.content = "test"
28
+ }
29
+
30
+ # Create a Table::Row object, add a Data object explicitly (with some
31
+ # configuration to boot)
32
+ row2 = Table::Row.new{ |r|
33
+ r.bgcolor = "blue"
34
+ r.align = "right"
35
+ r.content = Table::Row::Data.new{ |d|
36
+ d.content = "hello world!"
37
+ d.abbr = "test abbr"
38
+ }
39
+ }
40
+
41
+ # Add the rows explicitly to the table
42
+ table.push row1, row2
43
+
44
+ # Let's configure the row that contains "foo","bar","baz"
45
+ # Remember, row and column counts start at 0, not 1
46
+ table.configure(0){ |r|
47
+ r.bgcolor = "green"
48
+ r.align = "right"
49
+ }
50
+
51
+ puts table.html
52
+
53
+ =begin
54
+ ### OUTPUT ###
55
+ <table border=1 align='left'>
56
+ <tr bgcolor='green' align='right'>
57
+ <td>foo</td>
58
+ <td>bar</td>
59
+ <td>baz</td>
60
+ </tr>
61
+ <tr>
62
+ <td>1</td>
63
+ <td>2</td>
64
+ </tr>
65
+ <tr bgcolor='red' nowrap>
66
+ <td>test</td>
67
+ </tr>
68
+ <tr bgcolor='blue' align='right'>
69
+ <td abbr='test abbr'>hello world!</td>
70
+ </tr>
71
+ </table>
72
+ =end
@@ -1,62 +1,62 @@
1
- ##############################################################################
2
- # intermediate2.rb
3
- #
4
- # A slightly more advanced HTML Table. This time we'll add some attributes,
5
- # add a few rows both implicitly and explicitly, then configure it
6
- # after-the-fact. We'll also play with Captions and Headers and generally
7
- # do things slightly different that intermdiate1.rb.
8
- #
9
- # You can run this via the "example:intermediate2" rake task.
10
- ##############################################################################
11
- require 'html/table'
12
- include HTML
13
-
14
- table = Table.new
15
- table.border = 1
16
- table.cellpadding = 5
17
-
18
- caption = Table::Caption.new
19
- caption.content = "This is a caption!"
20
-
21
- row1 = Table::Row.new
22
- row2 = Table::Row.new
23
-
24
- row1.bgcolor = "red"
25
- row2.bgcolor = "blue"
26
-
27
- d1 = Table::Row::Data.new{ |d| d.content = "foo" }
28
- d2 = Table::Row::Data.new{ |d| d.content = "bar" }
29
- d3 = Table::Row::Data.new{ |d| d.content = "baz" }
30
-
31
- row1[0..2] = d1, d2, d3
32
-
33
- d4 = Table::Row::Data.new{ |d| d.content = "hello" }
34
- d5 = Table::Row::Data.new{ |d| d.content = "world" }
35
-
36
- h1 = Table::Row::Header.new
37
- h1.content = "This is a header"
38
- h1.colspan = 2
39
-
40
- row2.unshift h1
41
- row2.push d4, d5
42
-
43
- table.push row1, row2
44
- table.push caption # automatically bumped to row 0
45
-
46
- puts table.html
47
-
48
- =begin
49
- <table border=1 cellpadding=5>
50
- <caption>This is a caption!</caption>
51
- <tr bgcolor='red'>
52
- <td>foo</td>
53
- <td>bar</td>
54
- <td>baz</td>
55
- </tr>
56
- <tr bgcolor='blue'>
57
- <th colspan=2>This is a header</th>
58
- <td>hello</td>
59
- <td>world</td>
60
- </tr>
61
- </table>
62
- =end
1
+ ##############################################################################
2
+ # intermediate2.rb
3
+ #
4
+ # A slightly more advanced HTML Table. This time we'll add some attributes,
5
+ # add a few rows both implicitly and explicitly, then configure it
6
+ # after-the-fact. We'll also play with Captions and Headers and generally
7
+ # do things slightly different that intermdiate1.rb.
8
+ #
9
+ # You can run this via the "example:intermediate2" rake task.
10
+ ##############################################################################
11
+ require 'html/table'
12
+ include HTML
13
+
14
+ table = Table.new
15
+ table.border = 1
16
+ table.cellpadding = 5
17
+
18
+ caption = Table::Caption.new
19
+ caption.content = "This is a caption!"
20
+
21
+ row1 = Table::Row.new
22
+ row2 = Table::Row.new
23
+
24
+ row1.bgcolor = "red"
25
+ row2.bgcolor = "blue"
26
+
27
+ d1 = Table::Row::Data.new{ |d| d.content = "foo" }
28
+ d2 = Table::Row::Data.new{ |d| d.content = "bar" }
29
+ d3 = Table::Row::Data.new{ |d| d.content = "baz" }
30
+
31
+ row1[0..2] = d1, d2, d3
32
+
33
+ d4 = Table::Row::Data.new{ |d| d.content = "hello" }
34
+ d5 = Table::Row::Data.new{ |d| d.content = "world" }
35
+
36
+ h1 = Table::Row::Header.new
37
+ h1.content = "This is a header"
38
+ h1.colspan = 2
39
+
40
+ row2.unshift h1
41
+ row2.push d4, d5
42
+
43
+ table.push row1, row2
44
+ table.push caption # automatically bumped to row 0
45
+
46
+ puts table.html
47
+
48
+ =begin
49
+ <table border=1 cellpadding=5>
50
+ <caption>This is a caption!</caption>
51
+ <tr bgcolor='red'>
52
+ <td>foo</td>
53
+ <td>bar</td>
54
+ <td>baz</td>
55
+ </tr>
56
+ <tr bgcolor='blue'>
57
+ <th colspan=2>This is a header</th>
58
+ <td>hello</td>
59
+ <td>world</td>
60
+ </tr>
61
+ </table>
62
+ =end
@@ -1,46 +1,46 @@
1
- #######################################################################
2
- # intermediate3.rb
3
- #
4
- # This example demonstrates some intermediate features, including the
5
- # DSL style syntax and physical tag handling.
6
- #
7
- # You can run this example via the "example:intermediate3" rake task.
8
- #######################################################################
9
- require 'html/table'
10
- include HTML
11
-
12
- # You can set physical tags inline using block syntax...
13
- table = Table.new do
14
- align 'left'
15
- bgcolor 'red'
16
- header [['header1', 'header2']]
17
- content [['foo', 'bar']]
18
- content [['baz', 'blah']] do
19
- underline true
20
- tt true
21
- end
22
- end
23
-
24
- # Or you can do it this way
25
- table[1][0].content.bold = true
26
- table[1][1].content.italic = true
27
-
28
- puts table.html
29
-
30
- =begin
31
- ### OUTPUT ###
32
- <table align='left' bgcolor='red'>
33
- <tr>
34
- <th>header1</th>
35
- <th>header2</th>
36
- </tr>
37
- <tr>
38
- <td><b>foo</b></td>
39
- <td><i>bar</i></td>
40
- </tr>
41
- <tr>
42
- <td><tt><u>baz</u></tt></td>
43
- <td><tt><u>blah</u></tt></td>
44
- </tr>
45
- </table>
46
- =end
1
+ #######################################################################
2
+ # intermediate3.rb
3
+ #
4
+ # This example demonstrates some intermediate features, including the
5
+ # DSL style syntax and physical tag handling.
6
+ #
7
+ # You can run this example via the "example:intermediate3" rake task.
8
+ #######################################################################
9
+ require 'html/table'
10
+ include HTML
11
+
12
+ # You can set physical tags inline using block syntax...
13
+ table = Table.new do
14
+ align 'left'
15
+ bgcolor 'red'
16
+ header [['header1', 'header2']]
17
+ content [['foo', 'bar']]
18
+ content [['baz', 'blah']] do
19
+ underline true
20
+ tt true
21
+ end
22
+ end
23
+
24
+ # Or you can do it this way
25
+ table[1][0].content.bold = true
26
+ table[1][1].content.italic = true
27
+
28
+ puts table.html
29
+
30
+ =begin
31
+ ### OUTPUT ###
32
+ <table align='left' bgcolor='red'>
33
+ <tr>
34
+ <th>header1</th>
35
+ <th>header2</th>
36
+ </tr>
37
+ <tr>
38
+ <td><b>foo</b></td>
39
+ <td><i>bar</i></td>
40
+ </tr>
41
+ <tr>
42
+ <td><tt><u>baz</u></tt></td>
43
+ <td><tt><u>blah</u></tt></td>
44
+ </tr>
45
+ </table>
46
+ =end
data/examples/simple1.rb CHANGED
@@ -1,39 +1,39 @@
1
- #######################################################################
2
- # simple1.rb
3
- #
4
- # Very plain HTML Table with rows and data implicitly created.
5
- #
6
- # You can run this example via the "example:sample1" rake task.
7
- #######################################################################
8
- require 'html/table'
9
- include HTML
10
-
11
- table = Table.new{ |t|
12
- t.content = [
13
- %w/foo bar baz/,
14
- %w/1 2 3/,
15
- %w/hello world/
16
- ]
17
- }
18
-
19
- puts table.html
20
-
21
- =begin
22
- ### OUTPUT ###
23
- <table>
24
- <tr>
25
- <td>foo</td>
26
- <td>bar</td>
27
- <td>baz</td>
28
- </tr>
29
- <tr>
30
- <td>1</td>
31
- <td>2</td>
32
- <td>3</td>
33
- </tr>
34
- <tr>
35
- <td>hello</td>
36
- <td>world</td>
37
- </tr>
38
- </table>
39
- =end
1
+ #######################################################################
2
+ # simple1.rb
3
+ #
4
+ # Very plain HTML Table with rows and data implicitly created.
5
+ #
6
+ # You can run this example via the "example:sample1" rake task.
7
+ #######################################################################
8
+ require 'html/table'
9
+ include HTML
10
+
11
+ table = Table.new{ |t|
12
+ t.content = [
13
+ %w/foo bar baz/,
14
+ %w/1 2 3/,
15
+ %w/hello world/
16
+ ]
17
+ }
18
+
19
+ puts table.html
20
+
21
+ =begin
22
+ ### OUTPUT ###
23
+ <table>
24
+ <tr>
25
+ <td>foo</td>
26
+ <td>bar</td>
27
+ <td>baz</td>
28
+ </tr>
29
+ <tr>
30
+ <td>1</td>
31
+ <td>2</td>
32
+ <td>3</td>
33
+ </tr>
34
+ <tr>
35
+ <td>hello</td>
36
+ <td>world</td>
37
+ </tr>
38
+ </table>
39
+ =end
data/examples/simple2.rb CHANGED
@@ -1,47 +1,47 @@
1
- #######################################################################
2
- # simple2.rb
3
- #
4
- # Very plain HTML Table with rows explicitly created and data
5
- # elements implicitly created. We also remove the end tags
6
- # and capitalize the HTML tags and attributes.
7
- #
8
- # You can run this sample via the "example:simple2" rake task.
9
- #######################################################################
10
- require 'html/table'
11
- include HTML
12
-
13
- Table.html_case = "upper"
14
- Table::Row.end_tags = false
15
- Table::Row::Data.end_tags = false
16
-
17
- table = Table.new
18
- tr1 = Table::Row.new
19
- tr2 = Table::Row.new
20
- tr3 = Table::Row.new
21
-
22
- tr1.content = "foo", "bar", "baz"
23
- tr2.content = 1,2,3
24
- tr3.content = %w/hello world/
25
-
26
- table.push(tr1,tr2,tr3)
27
-
28
- table[0][1].align = "left"
29
-
30
- puts table.html
31
-
32
- =begin
33
- ### OUTPUT ###
34
- <TABLE>
35
- <TR>
36
- <TD>foo
37
- <TD ALIGN='LEFT'>bar
38
- <TD>baz
39
- <TR>
40
- <TD>1
41
- <TD>2
42
- <TD>3
43
- <TR>
44
- <TD>hello
45
- <TD>world
46
- </TABLE>
47
- =end
1
+ #######################################################################
2
+ # simple2.rb
3
+ #
4
+ # Very plain HTML Table with rows explicitly created and data
5
+ # elements implicitly created. We also remove the end tags
6
+ # and capitalize the HTML tags and attributes.
7
+ #
8
+ # You can run this sample via the "example:simple2" rake task.
9
+ #######################################################################
10
+ require 'html/table'
11
+ include HTML
12
+
13
+ Table.html_case = "upper"
14
+ Table::Row.end_tags = false
15
+ Table::Row::Data.end_tags = false
16
+
17
+ table = Table.new
18
+ tr1 = Table::Row.new
19
+ tr2 = Table::Row.new
20
+ tr3 = Table::Row.new
21
+
22
+ tr1.content = "foo", "bar", "baz"
23
+ tr2.content = 1,2,3
24
+ tr3.content = %w/hello world/
25
+
26
+ table.push(tr1,tr2,tr3)
27
+
28
+ table[0][1].align = "left"
29
+
30
+ puts table.html
31
+
32
+ =begin
33
+ ### OUTPUT ###
34
+ <TABLE>
35
+ <TR>
36
+ <TD>foo
37
+ <TD ALIGN='LEFT'>bar
38
+ <TD>baz
39
+ <TR>
40
+ <TD>1
41
+ <TD>2
42
+ <TD>3
43
+ <TR>
44
+ <TD>hello
45
+ <TD>world
46
+ </TABLE>
47
+ =end