ruby-vpi 7.1.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HEADER +101 -0
- data/HISTORY +57 -37
- data/README +1 -1
- data/Rakefile +21 -13
- data/doc/src/manual.xml +5 -5
- data/doc/txt/manual.txt +10 -6
- data/doc/xhtml/background.organization.html +1 -1
- data/doc/xhtml/index.html +2 -2
- data/doc/xhtml/usage.tutorial.html +4 -4
- data/header.html +114 -0
- data/header.part.html +114 -0
- data/history.html +217 -68
- data/history.part.html +880 -0
- data/lib/ruby-vpi/rcov.rb +62 -0
- data/lib/ruby-vpi/rspec.rb +1 -1
- data/lib/ruby-vpi/xx.rb +761 -0
- data/lib/ruby-vpi.rb +13 -2
- data/memo.html +116 -1
- data/memo.part.html +86 -0
- data/readme.html +116 -1
- data/readme.part.html +21 -0
- data/ref/c/annotated.html +1 -1
- data/ref/c/common_8h.html +1 -1
- data/ref/c/files.html +1 -1
- data/ref/c/functions.html +1 -1
- data/ref/c/functions_vars.html +1 -1
- data/ref/c/globals.html +1 -1
- data/ref/c/globals_0x63.html +1 -1
- data/ref/c/globals_0x65.html +1 -1
- data/ref/c/globals_0x66.html +1 -1
- data/ref/c/globals_0x70.html +1 -1
- data/ref/c/globals_0x72.html +1 -1
- data/ref/c/globals_0x73.html +1 -1
- data/ref/c/globals_0x74.html +1 -1
- data/ref/c/globals_0x76.html +1 -1
- data/ref/c/globals_0x78.html +1 -1
- data/ref/c/globals_defs.html +1 -1
- data/ref/c/globals_defs_0x65.html +1 -1
- data/ref/c/globals_defs_0x70.html +1 -1
- data/ref/c/globals_defs_0x76.html +1 -1
- data/ref/c/globals_defs_0x78.html +1 -1
- data/ref/c/globals_enum.html +1 -1
- data/ref/c/globals_eval.html +1 -1
- data/ref/c/globals_func.html +1 -1
- data/ref/c/globals_type.html +1 -1
- data/ref/c/globals_vars.html +1 -1
- data/ref/c/hierarchy.html +1 -1
- data/ref/c/index.html +1 -1
- data/ref/c/relay_8cin.html +1 -1
- data/ref/c/relay_8hin.html +1 -1
- data/ref/c/ruby-vpi_8c.html +1 -1
- data/ref/c/structrelay____RubyOptions____def.html +1 -1
- data/ref/c/structt__cb__data.html +1 -1
- data/ref/c/structt__vpi__delay.html +1 -1
- data/ref/c/structt__vpi__error__info.html +1 -1
- data/ref/c/structt__vpi__strengthval.html +1 -1
- data/ref/c/structt__vpi__systf__data.html +1 -1
- data/ref/c/structt__vpi__time.html +1 -1
- data/ref/c/structt__vpi__value.html +1 -1
- data/ref/c/structt__vpi__vecval.html +1 -1
- data/ref/c/structt__vpi__vlog__info.html +1 -1
- data/ref/c/swig_8cin.html +1 -1
- data/ref/c/swig_8hin.html +1 -1
- data/ref/c/verilog_8h.html +1 -1
- data/ref/c/vlog_8cin.html +1 -1
- data/ref/c/vlog_8hin.html +1 -1
- data/ref/c/vpi__user_8h.html +1 -1
- data/ref/ruby/classes/ERB.html +5 -5
- data/ref/ruby/classes/ERB.src/{M000035.html → M000011.html} +0 -0
- data/ref/ruby/classes/FileUtils.html +10 -10
- data/ref/ruby/classes/FileUtils.src/{M000048.html → M000065.html} +0 -0
- data/ref/ruby/classes/FileUtils.src/{M000049.html → M000066.html} +0 -0
- data/ref/ruby/classes/ModuleInfo.html +10 -10
- data/ref/ruby/classes/ModuleInfo.src/{M000019.html → M000008.html} +0 -0
- data/ref/ruby/classes/ModuleInfo.src/{M000020.html → M000009.html} +0 -0
- data/ref/ruby/classes/OutputInfo.html +5 -5
- data/ref/ruby/classes/OutputInfo.src/{M000018.html → M000007.html} +0 -0
- data/ref/ruby/classes/RDoc.html +5 -5
- data/ref/ruby/classes/RDoc.src/{M000051.html → M000069.html} +0 -0
- data/ref/ruby/classes/RubyVPI.html +45 -5
- data/ref/ruby/classes/RubyVPI.src/M000067.html +50 -0
- data/ref/ruby/classes/RubyVPI.src/M000068.html +20 -0
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.html +35 -35
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000042.html → M000059.html} +0 -0
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000043.html → M000060.html} +0 -0
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000044.html → M000061.html} +0 -0
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000045.html → M000062.html} +1 -1
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000046.html → M000063.html} +0 -0
- data/ref/ruby/classes/SWIG/TYPE_p_unsigned_int.src/{M000047.html → M000064.html} +1 -1
- data/ref/ruby/classes/String.html +5 -5
- data/ref/ruby/classes/String.src/{M000034.html → M000012.html} +0 -0
- data/ref/ruby/classes/{ResettedCounterValue.html → Table.html} +41 -24
- data/ref/ruby/classes/Table.src/M000003.html +38 -0
- data/ref/ruby/classes/Table.src/M000004.html +18 -0
- data/ref/ruby/classes/Table.src/M000005.html +18 -0
- data/ref/ruby/classes/{InputGenerator.src/M000029.html → Table.src/M000006.html} +5 -5
- data/ref/ruby/classes/Template.html +5 -5
- data/ref/ruby/classes/Template.src/{M000027.html → M000010.html} +0 -0
- data/ref/ruby/classes/XX/Document.html +295 -0
- data/ref/ruby/classes/XX/Document.src/M000050.html +22 -0
- data/ref/ruby/classes/XX/Document.src/M000051.html +20 -0
- data/ref/ruby/classes/XX/Document.src/M000052.html +20 -0
- data/ref/ruby/classes/XX/Document.src/M000053.html +20 -0
- data/ref/ruby/classes/XX/Document.src/M000054.html +22 -0
- data/ref/ruby/classes/XX/Document.src/M000055.html +21 -0
- data/ref/ruby/classes/XX/Document.src/M000056.html +21 -0
- data/ref/ruby/classes/XX/Document.src/M000057.html +34 -0
- data/ref/ruby/classes/XX/Document.src/M000058.html +98 -0
- data/ref/ruby/{files/bin/generate_test_tpl/spec_rb.html → classes/XX/HTML4/Strict.html} +26 -28
- data/ref/ruby/classes/XX/HTML4/Strict.src/M000016.html +20 -0
- data/ref/ruby/classes/{CounterProto.html → XX/HTML4/Transitional.html} +19 -45
- data/ref/ruby/classes/XX/HTML4/Transitional.src/M000015.html +20 -0
- data/ref/ruby/classes/{MaximumCounterValue.html → XX/HTML4.html} +20 -34
- data/ref/ruby/classes/XX/HTML4.src/M000014.html +20 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.html +236 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000022.html +22 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000023.html +20 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000024.html +25 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000025.html +20 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000026.html +27 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000027.html +20 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000028.html +27 -0
- data/ref/ruby/classes/XX/Markup/ClassMethods.src/M000029.html +22 -0
- data/ref/ruby/{files/bin/generate_test_tpl/proto_rb.html → classes/XX/Markup/Error.html} +25 -21
- data/ref/ruby/classes/XX/Markup/InstanceMethods.html +474 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000030.html +56 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000031.html +33 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000032.html +31 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000033.html +48 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000034.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000035.html +31 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000036.html +32 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000037.html +32 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000038.html +28 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000039.html +23 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000040.html +26 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000041.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000042.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000043.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000044.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000045.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000046.html +21 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000047.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000048.html +20 -0
- data/ref/ruby/classes/XX/Markup/InstanceMethods.src/M000049.html +20 -0
- data/ref/ruby/classes/{TestHw5UnitModel.html → XX/Markup.html} +29 -49
- data/ref/ruby/classes/XX/Markup.src/M000021.html +28 -0
- data/ref/ruby/{files/samp/counter/counter_rspecTest_spec_rb.html → classes/XX/XHTML/Strict.html} +46 -50
- data/ref/ruby/classes/XX/XHTML/Strict.src/M000020.html +20 -0
- data/ref/ruby/classes/XX/XHTML/Transitional.html +138 -0
- data/ref/ruby/classes/XX/XHTML/Transitional.src/M000019.html +20 -0
- data/ref/ruby/classes/XX/XHTML.html +145 -0
- data/ref/ruby/classes/XX/XHTML.src/M000018.html +36 -0
- data/ref/ruby/classes/XX/XML.html +138 -0
- data/ref/ruby/classes/XX/XML.src/M000013.html +20 -0
- data/ref/ruby/classes/XX/XMLish.html +138 -0
- data/ref/ruby/classes/XX/XMLish.src/M000017.html +18 -0
- data/ref/ruby/{files/samp/counter/counter_unitTest_spec_rb.html → classes/XX.html} +39 -36
- data/ref/ruby/created.rid +1 -1
- data/ref/ruby/files/bin/generate_test_rb.html +6 -6
- data/ref/ruby/files/bin/generate_test_rb.src/{M000002.html → M000001.html} +0 -0
- data/ref/ruby/files/bin/header_to_ruby_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/erb_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/rake_rb.html +1 -1
- data/ref/ruby/files/{samp/pipelined_alu/hw5_unit_bench_rb.html → lib/ruby-vpi/rcov_rb.html} +8 -5
- data/ref/ruby/files/lib/ruby-vpi/rdoc_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/rspec_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/runner_proxy_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/runner_rb.html +6 -6
- data/ref/ruby/files/lib/ruby-vpi/runner_rb.src/{M000001.html → M000002.html} +0 -0
- data/ref/ruby/files/lib/ruby-vpi/vpi_util_rb.html +1 -1
- data/ref/ruby/files/lib/ruby-vpi/xx_rb.html +148 -0
- data/ref/ruby/files/lib/ruby-vpi_rb.html +2 -1
- data/ref/ruby/fr_class_index.html +15 -10
- data/ref/ruby/fr_file_index.html +2 -20
- data/ref/ruby/fr_method_index.html +69 -51
- data/ref/ruby/index.html +1 -1
- data/style.css +47 -0
- metadata +133 -109
- data/ref/ruby/classes/Counter.html +0 -258
- data/ref/ruby/classes/Counter.src/M000038.html +0 -20
- data/ref/ruby/classes/Counter.src/M000039.html +0 -22
- data/ref/ruby/classes/Counter.src/M000040.html +0 -20
- data/ref/ruby/classes/Counter.src/M000041.html +0 -22
- data/ref/ruby/classes/CounterProto.src/M000005.html +0 -22
- data/ref/ruby/classes/CounterProto.src/M000006.html +0 -22
- data/ref/ruby/classes/Hw5UnitModel/Operation.html +0 -216
- data/ref/ruby/classes/Hw5UnitModel/Operation.src/M000012.html +0 -25
- data/ref/ruby/classes/Hw5UnitModel/Operation.src/M000013.html +0 -33
- data/ref/ruby/classes/Hw5UnitModel/Operation.src/M000014.html +0 -18
- data/ref/ruby/classes/Hw5UnitModel.html +0 -256
- data/ref/ruby/classes/Hw5UnitModel.src/M000007.html +0 -24
- data/ref/ruby/classes/Hw5UnitModel.src/M000009.html +0 -20
- data/ref/ruby/classes/Hw5UnitModel.src/M000010.html +0 -38
- data/ref/ruby/classes/Hw5UnitModel.src/M000011.html +0 -22
- data/ref/ruby/classes/Hw5_unit.html +0 -196
- data/ref/ruby/classes/Hw5_unit.src/M000004.html +0 -27
- data/ref/ruby/classes/Hw5_unit_spec.html +0 -237
- data/ref/ruby/classes/Hw5_unit_spec.src/M000024.html +0 -21
- data/ref/ruby/classes/Hw5_unit_spec.src/M000025.html +0 -21
- data/ref/ruby/classes/Hw5_unit_spec.src/M000026.html +0 -67
- data/ref/ruby/classes/InputGenerator.html +0 -260
- data/ref/ruby/classes/InputGenerator.src/M000028.html +0 -18
- data/ref/ruby/classes/InputGenerator.src/M000030.html +0 -19
- data/ref/ruby/classes/InputGenerator.src/M000031.html +0 -38
- data/ref/ruby/classes/InputGenerator.src/M000032.html +0 -19
- data/ref/ruby/classes/InputGenerator.src/M000033.html +0 -19
- data/ref/ruby/classes/MaximumCounterValue.src/M000036.html +0 -23
- data/ref/ruby/classes/MaximumCounterValue.src/M000037.html +0 -21
- data/ref/ruby/classes/ResettedCounterValue.src/M000015.html +0 -19
- data/ref/ruby/classes/ResettedCounterValue.src/M000016.html +0 -18
- data/ref/ruby/classes/ResettedCounterValue.src/M000017.html +0 -23
- data/ref/ruby/classes/RubyVPI.src/M000050.html +0 -39
- data/ref/ruby/classes/TestHw5UnitModel.src/M000021.html +0 -19
- data/ref/ruby/classes/TestHw5UnitModel.src/M000022.html +0 -19
- data/ref/ruby/classes/TestHw5UnitModel.src/M000023.html +0 -64
- data/ref/ruby/files/bin/generate_test_tpl/bench_rb.html +0 -115
- data/ref/ruby/files/bin/generate_test_tpl/design_rb.html +0 -107
- data/ref/ruby/files/bin/generate_test_tpl/spec_rb.src/M000003.html +0 -22
- data/ref/ruby/files/ext/extconf_rb.html +0 -108
- data/ref/ruby/files/gem_extconf_rb.html +0 -114
- data/ref/ruby/files/samp/counter/counter_rspecTest_bench_rb.html +0 -115
- data/ref/ruby/files/samp/counter/counter_rspecTest_design_rb.html +0 -107
- data/ref/ruby/files/samp/counter/counter_rspecTest_proto_rb.html +0 -107
- data/ref/ruby/files/samp/counter/counter_unitTest_bench_rb.html +0 -115
- data/ref/ruby/files/samp/counter/counter_unitTest_design_rb.html +0 -107
- data/ref/ruby/files/samp/counter/counter_unitTest_proto_rb.html +0 -107
- data/ref/ruby/files/samp/pipelined_alu/Hw5UnitModel_rb.html +0 -101
- data/ref/ruby/files/samp/pipelined_alu/InputGenerator_rb.html +0 -101
- data/ref/ruby/files/samp/pipelined_alu/TestHw5UnitModel_rb.html +0 -111
- data/ref/ruby/files/samp/pipelined_alu/hw5_unit_design_rb.html +0 -107
- data/ref/ruby/files/samp/pipelined_alu/hw5_unit_spec_rb.html +0 -112
data/lib/ruby-vpi/xx.rb
ADDED
@@ -0,0 +1,761 @@
|
|
1
|
+
# xx can be redistributed and used under the following conditions
|
2
|
+
# (just keep the following copyright notice, list of conditions and disclaimer
|
3
|
+
# in order to satisfy rcov's "Ruby license" and xx's license simultaneously).
|
4
|
+
#
|
5
|
+
#ePark Labs Public License version 1
|
6
|
+
#Copyright (c) 2005, ePark Labs, Inc. and contributors
|
7
|
+
#All rights reserved.
|
8
|
+
#
|
9
|
+
#Redistribution and use in source and binary forms, with or without modification,
|
10
|
+
#are permitted provided that the following conditions are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
13
|
+
# list of conditions and the following disclaimer.
|
14
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
# 3. Neither the name of ePark Labs nor the names of its contributors may be
|
18
|
+
# used to endorse or promote products derived from this software without
|
19
|
+
# specific prior written permission.
|
20
|
+
#
|
21
|
+
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
22
|
+
#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
23
|
+
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
24
|
+
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
25
|
+
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
26
|
+
#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
27
|
+
#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
28
|
+
#ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
30
|
+
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
|
32
|
+
unless defined? $__xx_rb__
|
33
|
+
|
34
|
+
require "rexml/document"
|
35
|
+
|
36
|
+
|
37
|
+
module XX
|
38
|
+
#--{{{
|
39
|
+
VERSION = "0.1.0"
|
40
|
+
|
41
|
+
%w(
|
42
|
+
CRAZY_LIKE_A_HELL
|
43
|
+
PERMISSIVE
|
44
|
+
STRICT
|
45
|
+
ANY
|
46
|
+
).each{|c| const_set c, c}
|
47
|
+
|
48
|
+
class Document
|
49
|
+
#--{{{
|
50
|
+
attr "doc"
|
51
|
+
attr "stack"
|
52
|
+
attr "size"
|
53
|
+
|
54
|
+
def initialize *a, &b
|
55
|
+
#--{{{
|
56
|
+
@doc = ::REXML::Document::new(*a, &b)
|
57
|
+
@stack = [@doc]
|
58
|
+
@size = 0
|
59
|
+
#--}}}
|
60
|
+
end
|
61
|
+
def top
|
62
|
+
#--{{{
|
63
|
+
@stack.last
|
64
|
+
#--}}}
|
65
|
+
end
|
66
|
+
def push element
|
67
|
+
#--{{{
|
68
|
+
@stack.push element
|
69
|
+
#--}}}
|
70
|
+
end
|
71
|
+
def pop
|
72
|
+
#--{{{
|
73
|
+
@stack.pop unless @stack.size == 1
|
74
|
+
#--}}}
|
75
|
+
end
|
76
|
+
def tracking_additions
|
77
|
+
#--{{{
|
78
|
+
n = @size
|
79
|
+
yield
|
80
|
+
return @size - n
|
81
|
+
#--}}}
|
82
|
+
end
|
83
|
+
def to_str port = ""
|
84
|
+
#--{{{
|
85
|
+
@doc.write port, indent=-1, transitive=false, ie_hack=true
|
86
|
+
port
|
87
|
+
#--}}}
|
88
|
+
end
|
89
|
+
alias_method "to_s", "to_str"
|
90
|
+
def pretty port = ''
|
91
|
+
#--{{{
|
92
|
+
@doc.write port, indent=2, transitive=false, ie_hack=true
|
93
|
+
port
|
94
|
+
#--}}}
|
95
|
+
end
|
96
|
+
def create element
|
97
|
+
#--{{{
|
98
|
+
push element
|
99
|
+
begin
|
100
|
+
object = nil
|
101
|
+
additions =
|
102
|
+
tracking_additions do
|
103
|
+
object = yield element if block_given?
|
104
|
+
end
|
105
|
+
if object and additions.zero?
|
106
|
+
self << object
|
107
|
+
end
|
108
|
+
ensure
|
109
|
+
pop
|
110
|
+
end
|
111
|
+
self << element
|
112
|
+
element
|
113
|
+
#--}}}
|
114
|
+
end
|
115
|
+
def << object
|
116
|
+
#--{{{
|
117
|
+
t, x = top, object
|
118
|
+
|
119
|
+
if x
|
120
|
+
case t
|
121
|
+
when ::REXML::Document
|
122
|
+
|
123
|
+
begin
|
124
|
+
t <<
|
125
|
+
case x
|
126
|
+
when ::REXML::Document
|
127
|
+
x.root || ::REXML::Text::new(x.to_s)
|
128
|
+
when ::REXML::Element
|
129
|
+
x
|
130
|
+
when ::REXML::CData
|
131
|
+
x
|
132
|
+
when ::REXML::Text
|
133
|
+
x
|
134
|
+
else # string
|
135
|
+
::REXML::Text::new(x.to_s)
|
136
|
+
end
|
137
|
+
rescue
|
138
|
+
if t.respond_to? "root"
|
139
|
+
t = t.root
|
140
|
+
retry
|
141
|
+
else
|
142
|
+
raise
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
when ::REXML::Element
|
147
|
+
t <<
|
148
|
+
case x
|
149
|
+
when ::REXML::Document
|
150
|
+
x.root || ::REXML::Text::new(x.to_s)
|
151
|
+
when ::REXML::Element
|
152
|
+
x
|
153
|
+
when ::REXML::CData
|
154
|
+
#::REXML::Text::new(x.write(""))
|
155
|
+
x
|
156
|
+
when ::REXML::Text
|
157
|
+
x
|
158
|
+
else # string
|
159
|
+
::REXML::Text::new(x.to_s)
|
160
|
+
end
|
161
|
+
|
162
|
+
when ::REXML::Text
|
163
|
+
t <<
|
164
|
+
case x
|
165
|
+
when ::REXML::Document
|
166
|
+
x.write ""
|
167
|
+
when ::REXML::Element
|
168
|
+
x.write ""
|
169
|
+
when ::REXML::CData
|
170
|
+
x.write ""
|
171
|
+
when ::REXML::Text
|
172
|
+
x.write ""
|
173
|
+
else # string
|
174
|
+
x.to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
else # other - try anyhow
|
178
|
+
t <<
|
179
|
+
case x
|
180
|
+
when ::REXML::Document
|
181
|
+
x.write ""
|
182
|
+
when ::REXML::Element
|
183
|
+
x.write ""
|
184
|
+
when ::REXML::CData
|
185
|
+
x.write ""
|
186
|
+
when ::REXML::Text
|
187
|
+
x.write ""
|
188
|
+
else # string
|
189
|
+
x.to_s
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
@size += 1
|
195
|
+
self
|
196
|
+
#--}}}
|
197
|
+
end
|
198
|
+
#--}}}
|
199
|
+
end
|
200
|
+
|
201
|
+
module Markup
|
202
|
+
#--{{{
|
203
|
+
class Error < ::StandardError; end
|
204
|
+
|
205
|
+
module InstanceMethods
|
206
|
+
#--{{{
|
207
|
+
def method_missing m, *a, &b
|
208
|
+
#--{{{
|
209
|
+
m = m.to_s
|
210
|
+
|
211
|
+
tag_method, tag_name = xx_class::xx_tag_method_name m
|
212
|
+
|
213
|
+
c_method_missing = xx_class::xx_config_for "method_missing", xx_which
|
214
|
+
c_tags = xx_class::xx_config_for "tags", xx_which
|
215
|
+
|
216
|
+
pat =
|
217
|
+
case c_method_missing
|
218
|
+
when ::XX::CRAZY_LIKE_A_HELL
|
219
|
+
%r/.*/
|
220
|
+
when ::XX::PERMISSIVE
|
221
|
+
%r/_$/o
|
222
|
+
when ::XX::STRICT
|
223
|
+
%r/_$/o
|
224
|
+
else
|
225
|
+
super
|
226
|
+
end
|
227
|
+
|
228
|
+
super unless m =~ pat
|
229
|
+
|
230
|
+
if c_method_missing == ::XX::STRICT
|
231
|
+
super unless c_tags.include? tag_name
|
232
|
+
end
|
233
|
+
|
234
|
+
ret, defined = nil
|
235
|
+
|
236
|
+
begin
|
237
|
+
xx_class::xx_define_tmp_method tag_method
|
238
|
+
xx_class::xx_define_tag_method tag_method, tag_name
|
239
|
+
ret = send tag_method, *a, &b
|
240
|
+
defined = true
|
241
|
+
ensure
|
242
|
+
xx_class::xx_remove_tag_method tag_method unless defined
|
243
|
+
end
|
244
|
+
|
245
|
+
ret
|
246
|
+
#--}}}
|
247
|
+
end
|
248
|
+
def xx_tag_ tag_name, *a, &b
|
249
|
+
#--{{{
|
250
|
+
tag_method, tag_name = xx_class::xx_tag_method_name tag_name
|
251
|
+
|
252
|
+
ret, defined = nil
|
253
|
+
|
254
|
+
begin
|
255
|
+
xx_class::xx_define_tmp_method tag_method
|
256
|
+
xx_class::xx_define_tag_method tag_method, tag_name
|
257
|
+
ret = send tag_method, *a, &b
|
258
|
+
defined = true
|
259
|
+
ensure
|
260
|
+
xx_class::xx_remove_tag_method tag_method unless defined
|
261
|
+
end
|
262
|
+
|
263
|
+
ret
|
264
|
+
#--}}}
|
265
|
+
end
|
266
|
+
alias_method "g_", "xx_tag_"
|
267
|
+
def xx_which *argv
|
268
|
+
#--{{{
|
269
|
+
@xx_which = nil unless defined? @xx_which
|
270
|
+
if argv.empty?
|
271
|
+
@xx_which
|
272
|
+
else
|
273
|
+
xx_which = @xx_which
|
274
|
+
begin
|
275
|
+
@xx_which = argv.shift
|
276
|
+
return yield
|
277
|
+
ensure
|
278
|
+
@xx_which = xx_which
|
279
|
+
end
|
280
|
+
end
|
281
|
+
#--}}}
|
282
|
+
end
|
283
|
+
def xx_with_doc_in_effect *a, &b
|
284
|
+
#--{{{
|
285
|
+
@xx_docs ||= []
|
286
|
+
doc = ::XX::Document::new(*a)
|
287
|
+
ddoc = doc.doc
|
288
|
+
begin
|
289
|
+
@xx_docs.push doc
|
290
|
+
b.call doc if b
|
291
|
+
|
292
|
+
doctype = xx_config_for "doctype", xx_which
|
293
|
+
if doctype
|
294
|
+
unless ddoc.doctype
|
295
|
+
doctype = ::REXML::DocType::new doctype unless
|
296
|
+
::REXML::DocType === doctype
|
297
|
+
ddoc << doctype
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
xmldecl = xx_config_for "xmldecl", xx_which
|
302
|
+
if xmldecl
|
303
|
+
if ddoc.xml_decl == ::REXML::XMLDecl::default
|
304
|
+
xmldecl = ::REXML::XMLDecl::new xmldecl unless
|
305
|
+
::REXML::XMLDecl === xmldecl
|
306
|
+
ddoc << xmldecl
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
return doc
|
311
|
+
ensure
|
312
|
+
@xx_docs.pop
|
313
|
+
end
|
314
|
+
#--}}}
|
315
|
+
end
|
316
|
+
def xx_doc
|
317
|
+
#--{{{
|
318
|
+
@xx_docs.last rescue raise "no xx_doc in effect!"
|
319
|
+
#--}}}
|
320
|
+
end
|
321
|
+
def xx_text_ *objects, &b
|
322
|
+
#--{{{
|
323
|
+
doc = xx_doc
|
324
|
+
|
325
|
+
text =
|
326
|
+
::REXML::Text::new("",
|
327
|
+
respect_whitespace=true, parent=nil
|
328
|
+
)
|
329
|
+
|
330
|
+
objects.each do |object|
|
331
|
+
text << object.to_s if object
|
332
|
+
end
|
333
|
+
|
334
|
+
doc.create text, &b
|
335
|
+
#--}}}
|
336
|
+
end
|
337
|
+
alias_method "text_", "xx_text_"
|
338
|
+
alias_method "t_", "xx_text_"
|
339
|
+
def xx_markup_ *objects, &b
|
340
|
+
#--{{{
|
341
|
+
doc = xx_doc
|
342
|
+
|
343
|
+
doc2 = ::REXML::Document::new ""
|
344
|
+
|
345
|
+
objects.each do |object|
|
346
|
+
(doc2.root ? doc2.root : doc2) << ::REXML::Document::new(object.to_s)
|
347
|
+
end
|
348
|
+
|
349
|
+
|
350
|
+
ret = doc.create doc2, &b
|
351
|
+
puts doc2.to_s
|
352
|
+
STDIN.gets
|
353
|
+
ret
|
354
|
+
#--}}}
|
355
|
+
end
|
356
|
+
alias_method "x_", "xx_markup_"
|
357
|
+
def xx_any_ *objects, &b
|
358
|
+
#--{{{
|
359
|
+
doc = xx_doc
|
360
|
+
nothing = %r/.^/m
|
361
|
+
|
362
|
+
text =
|
363
|
+
::REXML::Text::new("",
|
364
|
+
respect_whitespace=true, parent=nil, raw=true, entity_filter=nil, illegal=nothing
|
365
|
+
)
|
366
|
+
|
367
|
+
objects.each do |object|
|
368
|
+
text << object.to_s if object
|
369
|
+
end
|
370
|
+
|
371
|
+
doc.create text, &b
|
372
|
+
#--}}}
|
373
|
+
end
|
374
|
+
alias_method "h_", "xx_any_"
|
375
|
+
remove_method "x_" if instance_methods.include? "x_"
|
376
|
+
alias_method "x_", "xx_any_" # supplant for now
|
377
|
+
def xx_cdata_ *objects, &b
|
378
|
+
#--{{{
|
379
|
+
doc = xx_doc
|
380
|
+
|
381
|
+
cdata = ::REXML::CData::new ""
|
382
|
+
|
383
|
+
objects.each do |object|
|
384
|
+
cdata << object.to_s if object
|
385
|
+
end
|
386
|
+
|
387
|
+
doc.create cdata, &b
|
388
|
+
#--}}}
|
389
|
+
end
|
390
|
+
alias_method "c_", "xx_cdata_"
|
391
|
+
def xx_parse_attributes string
|
392
|
+
#--{{{
|
393
|
+
string = string.to_s
|
394
|
+
tokens = string.split %r/,/o
|
395
|
+
tokens.map{|t| t.sub!(%r/[^=]+=/){|key_eq| key_eq.chop << " : "}}
|
396
|
+
xx_parse_yaml_attributes(tokens.join(','))
|
397
|
+
#--}}}
|
398
|
+
end
|
399
|
+
alias_method "att_", "xx_parse_attributes"
|
400
|
+
def xx_parse_yaml_attributes string
|
401
|
+
#--{{{
|
402
|
+
require "yaml"
|
403
|
+
string = string.to_s
|
404
|
+
string = "{" << string unless string =~ %r/^\s*[{]/o
|
405
|
+
string = string << "}" unless string =~ %r/[}]\s*$/o
|
406
|
+
obj = ::YAML::load string
|
407
|
+
raise ArgumentError, "<#{ obj.class }> not Hash!" unless Hash === obj
|
408
|
+
obj
|
409
|
+
#--}}}
|
410
|
+
end
|
411
|
+
alias_method "at_", "xx_parse_yaml_attributes"
|
412
|
+
alias_method "yat_", "xx_parse_yaml_attributes"
|
413
|
+
def xx_class
|
414
|
+
#--{{{
|
415
|
+
@xx_class ||= self.class
|
416
|
+
#--}}}
|
417
|
+
end
|
418
|
+
def xx_tag_method_name *a, &b
|
419
|
+
#--{{{
|
420
|
+
xx_class.xx_tag_method_name(*a, &b)
|
421
|
+
#--}}}
|
422
|
+
end
|
423
|
+
def xx_define_tmp_method *a, &b
|
424
|
+
#--{{{
|
425
|
+
xx_class.xx_define_tmp_methodr(*a, &b)
|
426
|
+
#--}}}
|
427
|
+
end
|
428
|
+
def xx_define_tag_method *a, &b
|
429
|
+
#--{{{
|
430
|
+
xx_class.xx_define_tag_method(*a, &b)
|
431
|
+
#--}}}
|
432
|
+
end
|
433
|
+
def xx_remove_tag_method *a, &b
|
434
|
+
#--{{{
|
435
|
+
xx_class.xx_tag_remove_method(*a, &b)
|
436
|
+
#--}}}
|
437
|
+
end
|
438
|
+
def xx_ancestors
|
439
|
+
#--{{{
|
440
|
+
raise Error, "no xx_which in effect" unless xx_which
|
441
|
+
xx_class.xx_ancestors xx_which
|
442
|
+
#--}}}
|
443
|
+
end
|
444
|
+
def xx_config
|
445
|
+
#--{{{
|
446
|
+
xx_class.xx_config
|
447
|
+
#--}}}
|
448
|
+
end
|
449
|
+
def xx_config_for *a, &b
|
450
|
+
#--{{{
|
451
|
+
xx_class.xx_config_for(*a, &b)
|
452
|
+
#--}}}
|
453
|
+
end
|
454
|
+
def xx_configure *a, &b
|
455
|
+
#--{{{
|
456
|
+
xx_class.xx_configure(*a, &b)
|
457
|
+
#--}}}
|
458
|
+
end
|
459
|
+
#--}}}
|
460
|
+
end
|
461
|
+
|
462
|
+
module ClassMethods
|
463
|
+
#--{{{
|
464
|
+
def xx_tag_method_name m
|
465
|
+
#--{{{
|
466
|
+
m = m.to_s
|
467
|
+
tag_method, tag_name = m, m.gsub(%r/_+$/, "")
|
468
|
+
[ tag_method, tag_name ]
|
469
|
+
#--}}}
|
470
|
+
end
|
471
|
+
def xx_define_tmp_method m
|
472
|
+
#--{{{
|
473
|
+
define_method(m){ raise NotImplementedError, m.to_s }
|
474
|
+
#--}}}
|
475
|
+
end
|
476
|
+
def xx_define_tag_method tag_method, tag_name = nil
|
477
|
+
#--{{{
|
478
|
+
tag_method = tag_method.to_s
|
479
|
+
tag_name ||= tag_method.gsub %r/_+$/, ""
|
480
|
+
|
481
|
+
remove_method tag_method if instance_methods.include? tag_method
|
482
|
+
module_eval <<-code, __FILE__, __LINE__+1
|
483
|
+
def #{ tag_method } *a, &b
|
484
|
+
hashes, nothashes = a.partition{|x| Hash === x}
|
485
|
+
|
486
|
+
doc = xx_doc
|
487
|
+
element = ::REXML::Element::new '#{ tag_name }'
|
488
|
+
|
489
|
+
hashes.each{|h| h.each{|k,v| element.add_attribute k.to_s, v}}
|
490
|
+
nothashes.each{|nh| element << ::REXML::Text::new(nh.to_s)}
|
491
|
+
|
492
|
+
doc.create element, &b
|
493
|
+
end
|
494
|
+
code
|
495
|
+
tag_method
|
496
|
+
#--}}}
|
497
|
+
end
|
498
|
+
def xx_remove_tag_method tag_method
|
499
|
+
#--{{{
|
500
|
+
remove_method tag_method rescue nil
|
501
|
+
#--}}}
|
502
|
+
end
|
503
|
+
def xx_ancestors xx_which = self
|
504
|
+
#--{{{
|
505
|
+
list = []
|
506
|
+
ancestors.each do |a|
|
507
|
+
list << a if a < xx_which
|
508
|
+
end
|
509
|
+
xx_which.ancestors.each do |a|
|
510
|
+
list << a if a <= Markup
|
511
|
+
end
|
512
|
+
list
|
513
|
+
#--}}}
|
514
|
+
end
|
515
|
+
def xx_config
|
516
|
+
#--{{{
|
517
|
+
@@xx_config ||= Hash::new{|h,k| h[k] = {}}
|
518
|
+
#--}}}
|
519
|
+
end
|
520
|
+
def xx_config_for key, xx_which = nil
|
521
|
+
#--{{{
|
522
|
+
key = key.to_s
|
523
|
+
xx_which ||= self
|
524
|
+
xx_ancestors(xx_which).each do |a|
|
525
|
+
if xx_config[a].has_key? key
|
526
|
+
return xx_config[a][key]
|
527
|
+
end
|
528
|
+
end
|
529
|
+
nil
|
530
|
+
#--}}}
|
531
|
+
end
|
532
|
+
def xx_configure key, value, xx_which = nil
|
533
|
+
#--{{{
|
534
|
+
key = key.to_s
|
535
|
+
xx_which ||= self
|
536
|
+
xx_config[xx_which][key] = value
|
537
|
+
#--}}}
|
538
|
+
end
|
539
|
+
#--}}}
|
540
|
+
end
|
541
|
+
|
542
|
+
extend ClassMethods
|
543
|
+
include InstanceMethods
|
544
|
+
|
545
|
+
def self::included other, *a, &b
|
546
|
+
#--{{{
|
547
|
+
ret = super
|
548
|
+
other.module_eval do
|
549
|
+
include Markup::InstanceMethods
|
550
|
+
extend Markup::ClassMethods
|
551
|
+
class << self
|
552
|
+
define_method("included", Markup::XX_MARKUP_RECURSIVE_INCLUSION_PROC)
|
553
|
+
end
|
554
|
+
end
|
555
|
+
ret
|
556
|
+
#--}}}
|
557
|
+
end
|
558
|
+
XX_MARKUP_RECURSIVE_INCLUSION_PROC = method("included").to_proc
|
559
|
+
|
560
|
+
xx_configure "method_missing", XX::PERMISSIVE
|
561
|
+
xx_configure "tags", []
|
562
|
+
xx_configure "doctype", nil
|
563
|
+
xx_configure "xmldecl", nil
|
564
|
+
#--}}}
|
565
|
+
end
|
566
|
+
|
567
|
+
module XHTML
|
568
|
+
#--{{{
|
569
|
+
include Markup
|
570
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
|
571
|
+
|
572
|
+
def xhtml_ which = XHTML, *a, &b
|
573
|
+
#--{{{
|
574
|
+
xx_which(which) do
|
575
|
+
doc = xx_with_doc_in_effect(*a, &b)
|
576
|
+
ddoc = doc.doc
|
577
|
+
root = ddoc.root
|
578
|
+
if root and root.name and root.name =~ %r/^html$/i
|
579
|
+
if root.attribute("lang",nil).nil? or root.attribute("lang",nil).to_s.empty?
|
580
|
+
root.add_attribute "lang", "en"
|
581
|
+
end
|
582
|
+
if root.attribute("xml:lang").nil? or root.attribute("xml:lang").to_s.empty?
|
583
|
+
root.add_attribute "xml:lang", "en"
|
584
|
+
end
|
585
|
+
if root.namespace.nil? or root.namespace.to_s.empty?
|
586
|
+
root.add_namespace "http://www.w3.org/1999/xhtml"
|
587
|
+
end
|
588
|
+
end
|
589
|
+
doc
|
590
|
+
end
|
591
|
+
#--}}}
|
592
|
+
end
|
593
|
+
|
594
|
+
module Strict
|
595
|
+
#--{{{
|
596
|
+
include XHTML
|
597
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")
|
598
|
+
xx_configure "tags", %w(
|
599
|
+
html head body div span DOCTYPE title link meta style p
|
600
|
+
h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
|
601
|
+
ins del dfn kbd pre samp var br a base img
|
602
|
+
area map object param ul ol li dl dt dd table
|
603
|
+
tr td th tbody thead tfoot col colgroup caption form input
|
604
|
+
textarea select option optgroup button label fieldset legend script noscript b
|
605
|
+
i tt sub sup big small hr
|
606
|
+
)
|
607
|
+
xx_configure "method_missing", ::XX::STRICT
|
608
|
+
|
609
|
+
def xhtml_ which = XHTML::Strict, *a, &b
|
610
|
+
#--{{{
|
611
|
+
super(which, *a, &b)
|
612
|
+
#--}}}
|
613
|
+
end
|
614
|
+
#--}}}
|
615
|
+
end
|
616
|
+
|
617
|
+
module Transitional
|
618
|
+
#--{{{
|
619
|
+
include XHTML
|
620
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
|
621
|
+
def xhtml_ which = XHTML::Transitional, *a, &b
|
622
|
+
#--{{{
|
623
|
+
super(which, *a, &b)
|
624
|
+
#--}}}
|
625
|
+
end
|
626
|
+
#--}}}
|
627
|
+
end
|
628
|
+
#--}}}
|
629
|
+
end
|
630
|
+
|
631
|
+
module HTML4
|
632
|
+
#--{{{
|
633
|
+
include Markup
|
634
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
|
635
|
+
|
636
|
+
def html4_ which = HTML4, *a, &b
|
637
|
+
#--{{{
|
638
|
+
xx_which(which){ xx_with_doc_in_effect(*a, &b) }
|
639
|
+
#--}}}
|
640
|
+
end
|
641
|
+
|
642
|
+
module Strict
|
643
|
+
#--{{{
|
644
|
+
include HTML4
|
645
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN")
|
646
|
+
xx_configure "tags", %w(
|
647
|
+
html head body div span DOCTYPE title link meta style p
|
648
|
+
h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
|
649
|
+
ins del dfn kbd pre samp var br a base img
|
650
|
+
area map object param ul ol li dl dt dd table
|
651
|
+
tr td th tbody thead tfoot col colgroup caption form input
|
652
|
+
textarea select option optgroup button label fieldset legend script noscript b
|
653
|
+
i tt sub sup big small hr
|
654
|
+
)
|
655
|
+
xx_configure "method_missing", ::XX::STRICT
|
656
|
+
def html4_ which = HTML4::Strict, *a, &b
|
657
|
+
#--{{{
|
658
|
+
super(which, *a, &b)
|
659
|
+
#--}}}
|
660
|
+
end
|
661
|
+
#--}}}
|
662
|
+
end
|
663
|
+
|
664
|
+
module Transitional
|
665
|
+
#--{{{
|
666
|
+
include HTML4
|
667
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
|
668
|
+
def html4_ which = HTML4::Transitional, *a, &b
|
669
|
+
#--{{{
|
670
|
+
super(which, *a, &b)
|
671
|
+
#--}}}
|
672
|
+
end
|
673
|
+
#--}}}
|
674
|
+
end
|
675
|
+
#--}}}
|
676
|
+
end
|
677
|
+
HTML = HTML4
|
678
|
+
|
679
|
+
module XML
|
680
|
+
#--{{{
|
681
|
+
include Markup
|
682
|
+
xx_configure "xmldecl", ::REXML::XMLDecl::new
|
683
|
+
|
684
|
+
def xml_ *a, &b
|
685
|
+
#--{{{
|
686
|
+
xx_which(XML){ xx_with_doc_in_effect(*a, &b)}
|
687
|
+
#--}}}
|
688
|
+
end
|
689
|
+
#--}}}
|
690
|
+
end
|
691
|
+
#--}}}
|
692
|
+
end
|
693
|
+
|
694
|
+
$__xx_rb__ = __FILE__
|
695
|
+
end
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
#
|
707
|
+
# simple examples - see samples/ dir for more complete examples
|
708
|
+
#
|
709
|
+
|
710
|
+
if __FILE__ == $0
|
711
|
+
|
712
|
+
class Table < ::Array
|
713
|
+
include XX::XHTML::Strict
|
714
|
+
include XX::HTML4::Strict
|
715
|
+
include XX::XML
|
716
|
+
|
717
|
+
def doc
|
718
|
+
html_{
|
719
|
+
head_{ title_{ "xhtml/html4/xml demo" } }
|
720
|
+
|
721
|
+
div_{
|
722
|
+
h_{ "< malformed html & un-escaped symbols" }
|
723
|
+
}
|
724
|
+
|
725
|
+
t_{ "escaped & text > <" }
|
726
|
+
|
727
|
+
x_{ "<any_valid> xml </any_valid>" }
|
728
|
+
|
729
|
+
div_(:style => :sweet){
|
730
|
+
em_ "this is a table"
|
731
|
+
|
732
|
+
table_(:width => 42, :height => 42){
|
733
|
+
each{|row| tr_{ row.each{|cell| td_ cell } } }
|
734
|
+
}
|
735
|
+
}
|
736
|
+
|
737
|
+
script_(:type => :dangerous){ cdata_{ "javascript" } }
|
738
|
+
}
|
739
|
+
end
|
740
|
+
def to_xhtml
|
741
|
+
xhtml_{ doc }
|
742
|
+
end
|
743
|
+
def to_html4
|
744
|
+
html4_{ doc }
|
745
|
+
end
|
746
|
+
def to_xml
|
747
|
+
xml_{ doc }
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
table = Table[ %w( 0 1 2 ), %w( a b c ) ]
|
752
|
+
|
753
|
+
methods = %w( to_xhtml to_html4 to_xml )
|
754
|
+
|
755
|
+
methods.each do |method|
|
756
|
+
2.times{ puts "-" * 42 }
|
757
|
+
puts(table.send(method).pretty)
|
758
|
+
puts
|
759
|
+
end
|
760
|
+
|
761
|
+
end
|