html-table 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -1
- data/MANIFEST +0 -1
- data/Rakefile +24 -24
- data/doc/table_content.rdoc +15 -15
- data/html-table-1.3.2.gem +0 -0
- data/html-table.gemspec +25 -0
- data/lib/html/attribute_handler.rb +411 -411
- data/lib/html/body.rb +38 -38
- data/lib/html/caption.rb +48 -46
- data/lib/html/col.rb +41 -38
- data/lib/html/colgroup.rb +113 -110
- data/lib/html/content.rb +18 -18
- data/lib/html/data.rb +68 -65
- 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 -185
- data/lib/html/table.rb +311 -255
- data/lib/html/tablesection.rb +48 -45
- data/lib/html/tag_handler.rb +123 -123
- data/test/tc_attribute_handler.rb +263 -273
- data/test/tc_body.rb +87 -97
- data/test/tc_caption.rb +80 -90
- data/test/tc_col.rb +40 -50
- data/test/tc_colgroup.rb +89 -99
- data/test/tc_data.rb +77 -87
- data/test/tc_foot.rb +108 -118
- data/test/tc_head.rb +104 -114
- data/test/tc_header.rb +77 -87
- data/test/tc_html_handler.rb +37 -47
- data/test/tc_row.rb +141 -151
- data/test/tc_table.rb +154 -163
- data/test/tc_tablesection.rb +42 -52
- data/test/tc_tag_handler.rb +82 -92
- metadata +29 -10
- data/test/ts_all.rb +0 -24
data/CHANGES
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
== 1.3.2 - 15-Jul-2008
|
2
|
+
* Added to_s and to_str aliases for the html method for all classes.
|
3
|
+
* Some documentation updates.
|
4
|
+
* Removed unnecessary presetup code from the test files that was no longer
|
5
|
+
necessary thanks to Rake.
|
6
|
+
* Removed the ts_all.rb file. It was no longer necessary thanks to Rake.
|
7
|
+
|
1
8
|
== 1.3.1 - 8-Feb-2008
|
2
9
|
* Fully qualified the HTML::Table class in the HTMLHandler module. This fix
|
3
|
-
eliminates the need to 'include HTML' to actually some code to work
|
10
|
+
eliminates the need to 'include HTML' to actually get some code to work
|
4
11
|
properly. Thanks go to Jos Backus for the spot and patch.
|
5
12
|
* Added a Rakefile with tasks for testing and installation.
|
6
13
|
* Removed the install.rb file. That's now handled by the Rakefile.
|
data/MANIFEST
CHANGED
data/Rakefile
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
|
4
|
-
desc "Install the html-table package (non-gem)"
|
5
|
-
task :install do
|
6
|
-
dest = File.join(Config::CONFIG['sitelibdir'], 'html')
|
7
|
-
Dir.mkdir(dest) unless File.exists? dest
|
8
|
-
Dir['lib/html/*.rb'].each{ |f|
|
9
|
-
cp f, dest, :verbose => true
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "Install the html-table package as a gem"
|
14
|
-
task :install_gem do
|
15
|
-
ruby 'html-table.gemspec'
|
16
|
-
file = Dir["*.gem"].first
|
17
|
-
sh "gem install #{file}"
|
18
|
-
end
|
19
|
-
|
20
|
-
Rake::TestTask.new do |t|
|
21
|
-
t.libs << 'lib'
|
22
|
-
t.warning = true
|
23
|
-
t.test_files = FileList['test/tc*']
|
24
|
-
end
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc "Install the html-table package (non-gem)"
|
5
|
+
task :install do
|
6
|
+
dest = File.join(Config::CONFIG['sitelibdir'], 'html')
|
7
|
+
Dir.mkdir(dest) unless File.exists? dest
|
8
|
+
Dir['lib/html/*.rb'].each{ |f|
|
9
|
+
cp f, dest, :verbose => true
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Install the html-table package as a gem"
|
14
|
+
task :install_gem do
|
15
|
+
ruby 'html-table.gemspec'
|
16
|
+
file = Dir["*.gem"].first
|
17
|
+
sh "gem install #{file}"
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::TestTask.new do |t|
|
21
|
+
t.libs << 'lib'
|
22
|
+
t.warning = true
|
23
|
+
t.test_files = FileList['test/tc*']
|
24
|
+
end
|
data/doc/table_content.rdoc
CHANGED
@@ -1,15 +1,15 @@
|
|
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
|
-
content = Table::Content.new('my content') do
|
12
|
-
bold true
|
13
|
-
italics true
|
14
|
-
underline true
|
15
|
-
end
|
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
|
+
content = Table::Content.new('my content') do
|
12
|
+
bold true
|
13
|
+
italics true
|
14
|
+
underline true
|
15
|
+
end
|
File without changes
|
data/html-table.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'html-table'
|
5
|
+
gem.version = '1.3.2'
|
6
|
+
gem.author = 'Daniel J. Berger'
|
7
|
+
gem.email = 'djberg96@gmail.com'
|
8
|
+
gem.homepage = 'http://shards.rubyforge.org'
|
9
|
+
gem.rubyforge_project = 'shards'
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
11
|
+
gem.summary = 'A Ruby interface for generating HTML tables'
|
12
|
+
gem.description = 'A Ruby interface for generating HTML tables'
|
13
|
+
gem.test_files = Dir['test/*.rb']
|
14
|
+
gem.has_rdoc = true
|
15
|
+
gem.files = Dir['lib/html/*'] + Dir['[A-Z]*'] + Dir['test/*'] + Dir['doc/*']
|
16
|
+
gem.files.reject! { |fn| fn.include? 'CVS' }
|
17
|
+
gem.extra_rdoc_files = ['README', 'CHANGES'] + Dir['doc/*.rdoc']
|
18
|
+
gem.require_path = 'lib'
|
19
|
+
gem.add_dependency('strongtyping')
|
20
|
+
end
|
21
|
+
|
22
|
+
if $0 == __FILE__
|
23
|
+
Gem.manage_gems
|
24
|
+
Gem::Builder.new(spec).build
|
25
|
+
end
|
@@ -1,411 +1,411 @@
|
|
1
|
-
# This module creates methods for each of the various attributes associated
|
2
|
-
# with HTML tables. In some cases validation is done on the setters.
|
3
|
-
#--
|
4
|
-
# The seemingly redundant writer methods were left here for backwards
|
5
|
-
# compatibility and for those who may not prefer the DSI.
|
6
|
-
#
|
7
|
-
module AttributeHandler
|
8
|
-
def abbr(string = nil)
|
9
|
-
@abbr ||= nil
|
10
|
-
self.abbr = string if string
|
11
|
-
@abbr
|
12
|
-
end
|
13
|
-
|
14
|
-
def abbr=(string)
|
15
|
-
@abbr = string
|
16
|
-
modify_html("abbr", string)
|
17
|
-
end
|
18
|
-
|
19
|
-
def align(position = nil)
|
20
|
-
@align ||= nil
|
21
|
-
self.align = position if position
|
22
|
-
@align
|
23
|
-
end
|
24
|
-
|
25
|
-
def align=(position)
|
26
|
-
valid = %w/top bottom left center right/
|
27
|
-
raise ArgumentError unless valid.include?(position.downcase)
|
28
|
-
@align = position
|
29
|
-
modify_html("align", position)
|
30
|
-
end
|
31
|
-
|
32
|
-
def axis(string = nil)
|
33
|
-
@axis ||= nil
|
34
|
-
self.axis = string if string
|
35
|
-
@axis
|
36
|
-
end
|
37
|
-
|
38
|
-
def axis=(string)
|
39
|
-
@axis = string
|
40
|
-
modify_html("axis", string)
|
41
|
-
end
|
42
|
-
|
43
|
-
def background(url = nil)
|
44
|
-
@background ||= nil
|
45
|
-
self.background = url if url
|
46
|
-
@background
|
47
|
-
end
|
48
|
-
|
49
|
-
def background=(url)
|
50
|
-
raise TypeError unless url.kind_of?(String)
|
51
|
-
if $VERBOSE
|
52
|
-
msg = "'background' is a non-standard extension"
|
53
|
-
STDERR.puts msg
|
54
|
-
end
|
55
|
-
@background = url
|
56
|
-
modify_html("background", url)
|
57
|
-
end
|
58
|
-
|
59
|
-
def bgcolor(color = nil)
|
60
|
-
@bgcolor ||= nil
|
61
|
-
self.bgcolor = color if color
|
62
|
-
@bgcolor
|
63
|
-
end
|
64
|
-
|
65
|
-
def bgcolor=(color)
|
66
|
-
@bgcolor = color
|
67
|
-
modify_html("bgcolor", color)
|
68
|
-
end
|
69
|
-
|
70
|
-
def border(num = nil)
|
71
|
-
@border ||= nil
|
72
|
-
self.border = num if num
|
73
|
-
@border
|
74
|
-
end
|
75
|
-
|
76
|
-
# Allow either true/false or an integer
|
77
|
-
def border=(num)
|
78
|
-
if num.kind_of?(TrueClass)
|
79
|
-
modify_html("border", true)
|
80
|
-
elsif num.kind_of?(FalseClass)
|
81
|
-
# Do nothing
|
82
|
-
else
|
83
|
-
@border = num.to_i
|
84
|
-
modify_html("border", num.to_i)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def bordercolor(color = nil)
|
89
|
-
@bordercolor ||= nil
|
90
|
-
self.bordercolor = color if color
|
91
|
-
@bordercolor
|
92
|
-
end
|
93
|
-
|
94
|
-
def bordercolor=(color)
|
95
|
-
@bordercolor = color
|
96
|
-
if $VERBOSE
|
97
|
-
msg = "'bordercolor' is a non-standard extension"
|
98
|
-
STDERR.puts msg
|
99
|
-
end
|
100
|
-
modify_html("bordercolor", color)
|
101
|
-
end
|
102
|
-
|
103
|
-
def bordercolordark(color = nil)
|
104
|
-
@bordercolordark ||= nil
|
105
|
-
self.bordercolordark = color if color
|
106
|
-
@bordercolordark
|
107
|
-
end
|
108
|
-
|
109
|
-
def bordercolordark=(color)
|
110
|
-
@bordercolordark = color
|
111
|
-
if $VERBOSE
|
112
|
-
msg = "'bordercolordark' is a non-standard extension"
|
113
|
-
STDERR.puts msg
|
114
|
-
end
|
115
|
-
modify_html("bordercolordark", color)
|
116
|
-
end
|
117
|
-
|
118
|
-
def bordercolorlight(color = nil)
|
119
|
-
@bordercolorlight ||= nil
|
120
|
-
self.bordercolorlight = color if color
|
121
|
-
@bordercolorlight
|
122
|
-
end
|
123
|
-
|
124
|
-
def bordercolorlight=(color)
|
125
|
-
@bordercolorlight = color
|
126
|
-
if $VERBOSE
|
127
|
-
msg = "'bordercolorlight' is a non-standard extension"
|
128
|
-
STDERR.puts msg
|
129
|
-
end
|
130
|
-
modify_html("bordercolorlight", @bordercolorlight)
|
131
|
-
end
|
132
|
-
|
133
|
-
def cellpadding(num = nil)
|
134
|
-
@cellpadding ||= nil
|
135
|
-
self.cellpadding = num if num
|
136
|
-
@cellpadding
|
137
|
-
end
|
138
|
-
|
139
|
-
def cellpadding=(num)
|
140
|
-
raise ArgumentError if num.to_i < 0
|
141
|
-
@cellpadding = num.to_i
|
142
|
-
modify_html("cellpadding", @cellpadding)
|
143
|
-
end
|
144
|
-
|
145
|
-
def cellspacing(num = nil)
|
146
|
-
@cellspacing ||= nil
|
147
|
-
self.cellspacing = num if num
|
148
|
-
@cellspacing
|
149
|
-
end
|
150
|
-
|
151
|
-
def cellspacing=(num)
|
152
|
-
raise ArgumentError if num.to_i < 0
|
153
|
-
@cellspacing = num.to_i
|
154
|
-
modify_html("cellspacing", @cellspacing)
|
155
|
-
end
|
156
|
-
|
157
|
-
def char(character = nil)
|
158
|
-
@char ||= nil
|
159
|
-
self.char = character if character
|
160
|
-
@char
|
161
|
-
end
|
162
|
-
|
163
|
-
def char=(character)
|
164
|
-
raise ArgumentError if character.to_s.length > 1
|
165
|
-
@char = character.to_s
|
166
|
-
modify_html("char", character.to_s)
|
167
|
-
end
|
168
|
-
|
169
|
-
def charoff(offset = nil)
|
170
|
-
@charoff ||= nil
|
171
|
-
self.charoff = offset if offset
|
172
|
-
@charoff
|
173
|
-
end
|
174
|
-
|
175
|
-
def charoff=(offset)
|
176
|
-
raise ArgumentError if offset.to_i < 0
|
177
|
-
@charoff = offset
|
178
|
-
modify_html("charoff", offset)
|
179
|
-
end
|
180
|
-
|
181
|
-
# Returns the CSS class. The trailing underscore is necessary in order
|
182
|
-
# to avoid conflict with the 'class' keyword.
|
183
|
-
#
|
184
|
-
def class_(klass = nil)
|
185
|
-
@class ||= nil
|
186
|
-
self.class_ = klass if klass
|
187
|
-
@class
|
188
|
-
end
|
189
|
-
|
190
|
-
# Returns the CSS class. The trailing underscore is necessary in order
|
191
|
-
# to avoid conflict with the 'class' keyword.
|
192
|
-
#
|
193
|
-
def class_=(klass)
|
194
|
-
modify_html('class', klass)
|
195
|
-
@class = klass
|
196
|
-
end
|
197
|
-
|
198
|
-
def col(num = nil)
|
199
|
-
@col ||= nil
|
200
|
-
self.col = num if num
|
201
|
-
@col
|
202
|
-
end
|
203
|
-
|
204
|
-
def col=(num)
|
205
|
-
raise ArgumentError if num.to_i < 0
|
206
|
-
@col = num.to_i
|
207
|
-
modify_html("col", @col)
|
208
|
-
end
|
209
|
-
|
210
|
-
def colspan(span = nil)
|
211
|
-
@colspan ||= nil
|
212
|
-
self.colspan = span if span
|
213
|
-
@colspan
|
214
|
-
end
|
215
|
-
|
216
|
-
def colspan=(span)
|
217
|
-
raise ArgumentError if span.to_i < 0
|
218
|
-
@colspan = span.to_i
|
219
|
-
modify_html("colspan", @colspan)
|
220
|
-
end
|
221
|
-
|
222
|
-
# Allows you to configure various attributes by row or row + column.
|
223
|
-
#
|
224
|
-
def configure(row, col=nil, &block)
|
225
|
-
if col
|
226
|
-
begin
|
227
|
-
yield self[row][col]
|
228
|
-
rescue NameError
|
229
|
-
msg = "No column to configure in a " + self.class.to_s + " class"
|
230
|
-
raise ArgumentError, msg
|
231
|
-
end
|
232
|
-
else
|
233
|
-
yield self[row]
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
# Returns the HTML content (i.e. text).
|
238
|
-
#
|
239
|
-
def content(arg = nil, &block)
|
240
|
-
case arg
|
241
|
-
when String
|
242
|
-
self.content = Table::Content.new(arg, &block)
|
243
|
-
when Array
|
244
|
-
arg.each{ |e|
|
245
|
-
if e.kind_of?(Array)
|
246
|
-
row = Table::Row.new
|
247
|
-
e.each{ |element| row.push(Table::Content.new(element, &block)) }
|
248
|
-
self.push(row)
|
249
|
-
else
|
250
|
-
self.content = Table::Content.new(e, &block)
|
251
|
-
end
|
252
|
-
}
|
253
|
-
else
|
254
|
-
self.content = arg if arg
|
255
|
-
end
|
256
|
-
@html_body
|
257
|
-
end
|
258
|
-
|
259
|
-
alias data content
|
260
|
-
|
261
|
-
def frame(type = nil)
|
262
|
-
@frame ||= nil
|
263
|
-
self.frame = type if type
|
264
|
-
@frame
|
265
|
-
end
|
266
|
-
|
267
|
-
def frame=(type)
|
268
|
-
valid = %w/border void above below hsides lhs rhs vsides box/
|
269
|
-
raise ArgumentError unless valid.include?(type.downcase)
|
270
|
-
@frame = type
|
271
|
-
modify_html("frame", @frame)
|
272
|
-
end
|
273
|
-
|
274
|
-
def height(num = nil)
|
275
|
-
@height ||= nil
|
276
|
-
self.height = num if num
|
277
|
-
@height
|
278
|
-
end
|
279
|
-
|
280
|
-
def height=(num)
|
281
|
-
raise ArgumentError if num.to_i < 0
|
282
|
-
@height = num.to_i
|
283
|
-
modify_html("height", @height)
|
284
|
-
end
|
285
|
-
|
286
|
-
def hspace(num = nil)
|
287
|
-
@hspace ||= nil
|
288
|
-
self.hspace = num if num
|
289
|
-
@hspace
|
290
|
-
end
|
291
|
-
|
292
|
-
def hspace=(num)
|
293
|
-
raise ArgumentError if num.to_i < 0
|
294
|
-
@hspace = num.to_i
|
295
|
-
modify_html("hspace", @hspace)
|
296
|
-
end
|
297
|
-
|
298
|
-
def nowrap(bool = nil)
|
299
|
-
@nowrap ||= nil
|
300
|
-
self.nowrap = bool if bool
|
301
|
-
@nowrap
|
302
|
-
end
|
303
|
-
|
304
|
-
def nowrap=(bool)
|
305
|
-
unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass)
|
306
|
-
raise TypeError
|
307
|
-
end
|
308
|
-
@nowrap = bool
|
309
|
-
modify_html("nowrap", @nowrap)
|
310
|
-
end
|
311
|
-
|
312
|
-
def rowspan(num = nil)
|
313
|
-
@rowspan ||= nil
|
314
|
-
self.rowspan = num if num
|
315
|
-
@rowspan
|
316
|
-
end
|
317
|
-
|
318
|
-
def rowspan=(num)
|
319
|
-
raise ArgumentError if num.to_i < 0
|
320
|
-
@rowspan = num.to_i
|
321
|
-
modify_html("rowspan", @rowspan)
|
322
|
-
end
|
323
|
-
|
324
|
-
def rules(edges = nil)
|
325
|
-
@rules ||= nil
|
326
|
-
self.rules = edges if edges
|
327
|
-
@rules
|
328
|
-
end
|
329
|
-
|
330
|
-
def rules=(edges)
|
331
|
-
valid = %w/all groups rows cols none/
|
332
|
-
raise ArgumentError unless valid.include?(edges.to_s.downcase)
|
333
|
-
@rules = edges
|
334
|
-
modify_html("rules", @rules)
|
335
|
-
end
|
336
|
-
|
337
|
-
def span(num = nil)
|
338
|
-
@span ||= nil
|
339
|
-
self.span = num if num
|
340
|
-
@span
|
341
|
-
end
|
342
|
-
|
343
|
-
def span=(num)
|
344
|
-
raise ArgumentError if num.to_i < 0
|
345
|
-
@span = num.to_i
|
346
|
-
modify_html("span", @span)
|
347
|
-
end
|
348
|
-
|
349
|
-
def style(string = nil)
|
350
|
-
@style ||= nil
|
351
|
-
self.style = string if string
|
352
|
-
@style
|
353
|
-
end
|
354
|
-
|
355
|
-
def style=(string)
|
356
|
-
@style = string.to_s
|
357
|
-
modify_html("style", @style)
|
358
|
-
end
|
359
|
-
|
360
|
-
def summary(string = nil)
|
361
|
-
@summary ||= nil
|
362
|
-
self.summary = string if string
|
363
|
-
@summary
|
364
|
-
end
|
365
|
-
|
366
|
-
def summary=(string)
|
367
|
-
@summary = string.to_s
|
368
|
-
modify_html("summary", @summary)
|
369
|
-
end
|
370
|
-
|
371
|
-
def valign(position = nil)
|
372
|
-
@valign ||= nil
|
373
|
-
self.valign = position if position
|
374
|
-
@valign
|
375
|
-
end
|
376
|
-
|
377
|
-
def valign=(position)
|
378
|
-
valid = %w/top center bottom baseline/
|
379
|
-
raise ArgumentError unless valid.include?(position.to_s.downcase)
|
380
|
-
@valign = position
|
381
|
-
modify_html("valign", @valign)
|
382
|
-
end
|
383
|
-
|
384
|
-
def vspace(num = nil)
|
385
|
-
@vspace ||= nil
|
386
|
-
self.vspace = num if num
|
387
|
-
@vspace
|
388
|
-
end
|
389
|
-
|
390
|
-
def vspace=(num)
|
391
|
-
raise ArgumentError if num.to_i < 0
|
392
|
-
@vspace = num.to_i
|
393
|
-
modify_html("vspace", @vspace)
|
394
|
-
end
|
395
|
-
|
396
|
-
def width(num = nil)
|
397
|
-
@width ||= nil
|
398
|
-
self.width = num if num
|
399
|
-
@width
|
400
|
-
end
|
401
|
-
|
402
|
-
def width=(num)
|
403
|
-
if num =~ /%/
|
404
|
-
@width = num
|
405
|
-
else
|
406
|
-
raise ArgumentError if num.to_i < 0
|
407
|
-
@width = num.to_i
|
408
|
-
end
|
409
|
-
modify_html("width", @width)
|
410
|
-
end
|
411
|
-
end
|
1
|
+
# This module creates methods for each of the various attributes associated
|
2
|
+
# with HTML tables. In some cases validation is done on the setters.
|
3
|
+
#--
|
4
|
+
# The seemingly redundant writer methods were left here for backwards
|
5
|
+
# compatibility and for those who may not prefer the DSI.
|
6
|
+
#
|
7
|
+
module AttributeHandler
|
8
|
+
def abbr(string = nil)
|
9
|
+
@abbr ||= nil
|
10
|
+
self.abbr = string if string
|
11
|
+
@abbr
|
12
|
+
end
|
13
|
+
|
14
|
+
def abbr=(string)
|
15
|
+
@abbr = string
|
16
|
+
modify_html("abbr", string)
|
17
|
+
end
|
18
|
+
|
19
|
+
def align(position = nil)
|
20
|
+
@align ||= nil
|
21
|
+
self.align = position if position
|
22
|
+
@align
|
23
|
+
end
|
24
|
+
|
25
|
+
def align=(position)
|
26
|
+
valid = %w/top bottom left center right/
|
27
|
+
raise ArgumentError unless valid.include?(position.downcase)
|
28
|
+
@align = position
|
29
|
+
modify_html("align", position)
|
30
|
+
end
|
31
|
+
|
32
|
+
def axis(string = nil)
|
33
|
+
@axis ||= nil
|
34
|
+
self.axis = string if string
|
35
|
+
@axis
|
36
|
+
end
|
37
|
+
|
38
|
+
def axis=(string)
|
39
|
+
@axis = string
|
40
|
+
modify_html("axis", string)
|
41
|
+
end
|
42
|
+
|
43
|
+
def background(url = nil)
|
44
|
+
@background ||= nil
|
45
|
+
self.background = url if url
|
46
|
+
@background
|
47
|
+
end
|
48
|
+
|
49
|
+
def background=(url)
|
50
|
+
raise TypeError unless url.kind_of?(String)
|
51
|
+
if $VERBOSE
|
52
|
+
msg = "'background' is a non-standard extension"
|
53
|
+
STDERR.puts msg
|
54
|
+
end
|
55
|
+
@background = url
|
56
|
+
modify_html("background", url)
|
57
|
+
end
|
58
|
+
|
59
|
+
def bgcolor(color = nil)
|
60
|
+
@bgcolor ||= nil
|
61
|
+
self.bgcolor = color if color
|
62
|
+
@bgcolor
|
63
|
+
end
|
64
|
+
|
65
|
+
def bgcolor=(color)
|
66
|
+
@bgcolor = color
|
67
|
+
modify_html("bgcolor", color)
|
68
|
+
end
|
69
|
+
|
70
|
+
def border(num = nil)
|
71
|
+
@border ||= nil
|
72
|
+
self.border = num if num
|
73
|
+
@border
|
74
|
+
end
|
75
|
+
|
76
|
+
# Allow either true/false or an integer
|
77
|
+
def border=(num)
|
78
|
+
if num.kind_of?(TrueClass)
|
79
|
+
modify_html("border", true)
|
80
|
+
elsif num.kind_of?(FalseClass)
|
81
|
+
# Do nothing
|
82
|
+
else
|
83
|
+
@border = num.to_i
|
84
|
+
modify_html("border", num.to_i)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def bordercolor(color = nil)
|
89
|
+
@bordercolor ||= nil
|
90
|
+
self.bordercolor = color if color
|
91
|
+
@bordercolor
|
92
|
+
end
|
93
|
+
|
94
|
+
def bordercolor=(color)
|
95
|
+
@bordercolor = color
|
96
|
+
if $VERBOSE
|
97
|
+
msg = "'bordercolor' is a non-standard extension"
|
98
|
+
STDERR.puts msg
|
99
|
+
end
|
100
|
+
modify_html("bordercolor", color)
|
101
|
+
end
|
102
|
+
|
103
|
+
def bordercolordark(color = nil)
|
104
|
+
@bordercolordark ||= nil
|
105
|
+
self.bordercolordark = color if color
|
106
|
+
@bordercolordark
|
107
|
+
end
|
108
|
+
|
109
|
+
def bordercolordark=(color)
|
110
|
+
@bordercolordark = color
|
111
|
+
if $VERBOSE
|
112
|
+
msg = "'bordercolordark' is a non-standard extension"
|
113
|
+
STDERR.puts msg
|
114
|
+
end
|
115
|
+
modify_html("bordercolordark", color)
|
116
|
+
end
|
117
|
+
|
118
|
+
def bordercolorlight(color = nil)
|
119
|
+
@bordercolorlight ||= nil
|
120
|
+
self.bordercolorlight = color if color
|
121
|
+
@bordercolorlight
|
122
|
+
end
|
123
|
+
|
124
|
+
def bordercolorlight=(color)
|
125
|
+
@bordercolorlight = color
|
126
|
+
if $VERBOSE
|
127
|
+
msg = "'bordercolorlight' is a non-standard extension"
|
128
|
+
STDERR.puts msg
|
129
|
+
end
|
130
|
+
modify_html("bordercolorlight", @bordercolorlight)
|
131
|
+
end
|
132
|
+
|
133
|
+
def cellpadding(num = nil)
|
134
|
+
@cellpadding ||= nil
|
135
|
+
self.cellpadding = num if num
|
136
|
+
@cellpadding
|
137
|
+
end
|
138
|
+
|
139
|
+
def cellpadding=(num)
|
140
|
+
raise ArgumentError if num.to_i < 0
|
141
|
+
@cellpadding = num.to_i
|
142
|
+
modify_html("cellpadding", @cellpadding)
|
143
|
+
end
|
144
|
+
|
145
|
+
def cellspacing(num = nil)
|
146
|
+
@cellspacing ||= nil
|
147
|
+
self.cellspacing = num if num
|
148
|
+
@cellspacing
|
149
|
+
end
|
150
|
+
|
151
|
+
def cellspacing=(num)
|
152
|
+
raise ArgumentError if num.to_i < 0
|
153
|
+
@cellspacing = num.to_i
|
154
|
+
modify_html("cellspacing", @cellspacing)
|
155
|
+
end
|
156
|
+
|
157
|
+
def char(character = nil)
|
158
|
+
@char ||= nil
|
159
|
+
self.char = character if character
|
160
|
+
@char
|
161
|
+
end
|
162
|
+
|
163
|
+
def char=(character)
|
164
|
+
raise ArgumentError if character.to_s.length > 1
|
165
|
+
@char = character.to_s
|
166
|
+
modify_html("char", character.to_s)
|
167
|
+
end
|
168
|
+
|
169
|
+
def charoff(offset = nil)
|
170
|
+
@charoff ||= nil
|
171
|
+
self.charoff = offset if offset
|
172
|
+
@charoff
|
173
|
+
end
|
174
|
+
|
175
|
+
def charoff=(offset)
|
176
|
+
raise ArgumentError if offset.to_i < 0
|
177
|
+
@charoff = offset
|
178
|
+
modify_html("charoff", offset)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns the CSS class. The trailing underscore is necessary in order
|
182
|
+
# to avoid conflict with the 'class' keyword.
|
183
|
+
#
|
184
|
+
def class_(klass = nil)
|
185
|
+
@class ||= nil
|
186
|
+
self.class_ = klass if klass
|
187
|
+
@class
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the CSS class. The trailing underscore is necessary in order
|
191
|
+
# to avoid conflict with the 'class' keyword.
|
192
|
+
#
|
193
|
+
def class_=(klass)
|
194
|
+
modify_html('class', klass)
|
195
|
+
@class = klass
|
196
|
+
end
|
197
|
+
|
198
|
+
def col(num = nil)
|
199
|
+
@col ||= nil
|
200
|
+
self.col = num if num
|
201
|
+
@col
|
202
|
+
end
|
203
|
+
|
204
|
+
def col=(num)
|
205
|
+
raise ArgumentError if num.to_i < 0
|
206
|
+
@col = num.to_i
|
207
|
+
modify_html("col", @col)
|
208
|
+
end
|
209
|
+
|
210
|
+
def colspan(span = nil)
|
211
|
+
@colspan ||= nil
|
212
|
+
self.colspan = span if span
|
213
|
+
@colspan
|
214
|
+
end
|
215
|
+
|
216
|
+
def colspan=(span)
|
217
|
+
raise ArgumentError if span.to_i < 0
|
218
|
+
@colspan = span.to_i
|
219
|
+
modify_html("colspan", @colspan)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Allows you to configure various attributes by row or row + column.
|
223
|
+
#
|
224
|
+
def configure(row, col=nil, &block)
|
225
|
+
if col
|
226
|
+
begin
|
227
|
+
yield self[row][col]
|
228
|
+
rescue NameError
|
229
|
+
msg = "No column to configure in a " + self.class.to_s + " class"
|
230
|
+
raise ArgumentError, msg
|
231
|
+
end
|
232
|
+
else
|
233
|
+
yield self[row]
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the HTML content (i.e. text).
|
238
|
+
#
|
239
|
+
def content(arg = nil, &block)
|
240
|
+
case arg
|
241
|
+
when String
|
242
|
+
self.content = Table::Content.new(arg, &block)
|
243
|
+
when Array
|
244
|
+
arg.each{ |e|
|
245
|
+
if e.kind_of?(Array)
|
246
|
+
row = Table::Row.new
|
247
|
+
e.each{ |element| row.push(Table::Content.new(element, &block)) }
|
248
|
+
self.push(row)
|
249
|
+
else
|
250
|
+
self.content = Table::Content.new(e, &block)
|
251
|
+
end
|
252
|
+
}
|
253
|
+
else
|
254
|
+
self.content = arg if arg
|
255
|
+
end
|
256
|
+
@html_body
|
257
|
+
end
|
258
|
+
|
259
|
+
alias data content
|
260
|
+
|
261
|
+
def frame(type = nil)
|
262
|
+
@frame ||= nil
|
263
|
+
self.frame = type if type
|
264
|
+
@frame
|
265
|
+
end
|
266
|
+
|
267
|
+
def frame=(type)
|
268
|
+
valid = %w/border void above below hsides lhs rhs vsides box/
|
269
|
+
raise ArgumentError unless valid.include?(type.downcase)
|
270
|
+
@frame = type
|
271
|
+
modify_html("frame", @frame)
|
272
|
+
end
|
273
|
+
|
274
|
+
def height(num = nil)
|
275
|
+
@height ||= nil
|
276
|
+
self.height = num if num
|
277
|
+
@height
|
278
|
+
end
|
279
|
+
|
280
|
+
def height=(num)
|
281
|
+
raise ArgumentError if num.to_i < 0
|
282
|
+
@height = num.to_i
|
283
|
+
modify_html("height", @height)
|
284
|
+
end
|
285
|
+
|
286
|
+
def hspace(num = nil)
|
287
|
+
@hspace ||= nil
|
288
|
+
self.hspace = num if num
|
289
|
+
@hspace
|
290
|
+
end
|
291
|
+
|
292
|
+
def hspace=(num)
|
293
|
+
raise ArgumentError if num.to_i < 0
|
294
|
+
@hspace = num.to_i
|
295
|
+
modify_html("hspace", @hspace)
|
296
|
+
end
|
297
|
+
|
298
|
+
def nowrap(bool = nil)
|
299
|
+
@nowrap ||= nil
|
300
|
+
self.nowrap = bool if bool
|
301
|
+
@nowrap
|
302
|
+
end
|
303
|
+
|
304
|
+
def nowrap=(bool)
|
305
|
+
unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass)
|
306
|
+
raise TypeError
|
307
|
+
end
|
308
|
+
@nowrap = bool
|
309
|
+
modify_html("nowrap", @nowrap)
|
310
|
+
end
|
311
|
+
|
312
|
+
def rowspan(num = nil)
|
313
|
+
@rowspan ||= nil
|
314
|
+
self.rowspan = num if num
|
315
|
+
@rowspan
|
316
|
+
end
|
317
|
+
|
318
|
+
def rowspan=(num)
|
319
|
+
raise ArgumentError if num.to_i < 0
|
320
|
+
@rowspan = num.to_i
|
321
|
+
modify_html("rowspan", @rowspan)
|
322
|
+
end
|
323
|
+
|
324
|
+
def rules(edges = nil)
|
325
|
+
@rules ||= nil
|
326
|
+
self.rules = edges if edges
|
327
|
+
@rules
|
328
|
+
end
|
329
|
+
|
330
|
+
def rules=(edges)
|
331
|
+
valid = %w/all groups rows cols none/
|
332
|
+
raise ArgumentError unless valid.include?(edges.to_s.downcase)
|
333
|
+
@rules = edges
|
334
|
+
modify_html("rules", @rules)
|
335
|
+
end
|
336
|
+
|
337
|
+
def span(num = nil)
|
338
|
+
@span ||= nil
|
339
|
+
self.span = num if num
|
340
|
+
@span
|
341
|
+
end
|
342
|
+
|
343
|
+
def span=(num)
|
344
|
+
raise ArgumentError if num.to_i < 0
|
345
|
+
@span = num.to_i
|
346
|
+
modify_html("span", @span)
|
347
|
+
end
|
348
|
+
|
349
|
+
def style(string = nil)
|
350
|
+
@style ||= nil
|
351
|
+
self.style = string if string
|
352
|
+
@style
|
353
|
+
end
|
354
|
+
|
355
|
+
def style=(string)
|
356
|
+
@style = string.to_s
|
357
|
+
modify_html("style", @style)
|
358
|
+
end
|
359
|
+
|
360
|
+
def summary(string = nil)
|
361
|
+
@summary ||= nil
|
362
|
+
self.summary = string if string
|
363
|
+
@summary
|
364
|
+
end
|
365
|
+
|
366
|
+
def summary=(string)
|
367
|
+
@summary = string.to_s
|
368
|
+
modify_html("summary", @summary)
|
369
|
+
end
|
370
|
+
|
371
|
+
def valign(position = nil)
|
372
|
+
@valign ||= nil
|
373
|
+
self.valign = position if position
|
374
|
+
@valign
|
375
|
+
end
|
376
|
+
|
377
|
+
def valign=(position)
|
378
|
+
valid = %w/top center bottom baseline/
|
379
|
+
raise ArgumentError unless valid.include?(position.to_s.downcase)
|
380
|
+
@valign = position
|
381
|
+
modify_html("valign", @valign)
|
382
|
+
end
|
383
|
+
|
384
|
+
def vspace(num = nil)
|
385
|
+
@vspace ||= nil
|
386
|
+
self.vspace = num if num
|
387
|
+
@vspace
|
388
|
+
end
|
389
|
+
|
390
|
+
def vspace=(num)
|
391
|
+
raise ArgumentError if num.to_i < 0
|
392
|
+
@vspace = num.to_i
|
393
|
+
modify_html("vspace", @vspace)
|
394
|
+
end
|
395
|
+
|
396
|
+
def width(num = nil)
|
397
|
+
@width ||= nil
|
398
|
+
self.width = num if num
|
399
|
+
@width
|
400
|
+
end
|
401
|
+
|
402
|
+
def width=(num)
|
403
|
+
if num =~ /%/
|
404
|
+
@width = num
|
405
|
+
else
|
406
|
+
raise ArgumentError if num.to_i < 0
|
407
|
+
@width = num.to_i
|
408
|
+
end
|
409
|
+
modify_html("width", @width)
|
410
|
+
end
|
411
|
+
end
|