html-table 1.6.3 → 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 (81) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES.rdoc → CHANGES.md} +76 -68
  4. data/Gemfile +2 -0
  5. data/MANIFEST.md +57 -0
  6. data/{README.rdoc → README.md} +80 -71
  7. data/Rakefile +122 -146
  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 +16 -11
  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 +59 -55
  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 +374 -0
  39. data/spec/body_spec.rb +98 -0
  40. data/spec/caption_spec.rb +83 -0
  41. data/spec/colgroup_col_spec.rb +34 -0
  42. data/spec/colgroup_spec.rb +97 -0
  43. data/spec/data_spec.rb +88 -0
  44. data/spec/foot_spec.rb +116 -0
  45. data/spec/head_spec.rb +116 -0
  46. data/spec/header_spec.rb +85 -0
  47. data/spec/html_handler_spec.rb +35 -0
  48. data/spec/row_spec.rb +163 -0
  49. data/spec/table_spec.rb +186 -0
  50. data/spec/tablesection_spec.rb +36 -0
  51. data/spec/tag_handler_spec.rb +85 -0
  52. data.tar.gz.sig +0 -0
  53. metadata +118 -92
  54. metadata.gz.sig +0 -0
  55. data/MANIFEST.rdoc +0 -56
  56. data/doc/attributes.rdoc +0 -143
  57. data/doc/table.rdoc +0 -156
  58. data/doc/table_body.rdoc +0 -9
  59. data/doc/table_caption.rdoc +0 -9
  60. data/doc/table_colgroup.rdoc +0 -8
  61. data/doc/table_colgroup_col.rdoc +0 -9
  62. data/doc/table_content.rdoc +0 -15
  63. data/doc/table_foot.rdoc +0 -8
  64. data/doc/table_head.rdoc +0 -11
  65. data/doc/table_row.rdoc +0 -105
  66. data/doc/table_row_data.rdoc +0 -92
  67. data/doc/table_row_header.rdoc +0 -7
  68. data/test/test_attribute_handler.rb +0 -361
  69. data/test/test_body.rb +0 -87
  70. data/test/test_caption.rb +0 -80
  71. data/test/test_col.rb +0 -40
  72. data/test/test_colgroup.rb +0 -89
  73. data/test/test_data.rb +0 -77
  74. data/test/test_foot.rb +0 -111
  75. data/test/test_head.rb +0 -104
  76. data/test/test_header.rb +0 -77
  77. data/test/test_html_handler.rb +0 -37
  78. data/test/test_row.rb +0 -141
  79. data/test/test_table.rb +0 -159
  80. data/test/test_tablesection.rb +0 -42
  81. data/test/test_tag_handler.rb +0 -90
data/lib/html/data.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
3
 
3
4
  # This class represents HTML table data, <td>. Despite the name
@@ -6,6 +7,7 @@ module HTML
6
7
  class Table::Row::Data
7
8
  include HTML::Mixin::AttributeHandler
8
9
  include HTML::Mixin::HtmlHandler
10
+ extend HTML::Mixin::StrongTyping
9
11
 
10
12
  undef_method :configure
11
13
 
@@ -42,7 +44,7 @@ module HTML
42
44
  #
43
45
  def self.indent_level=(num)
44
46
  expect(num, Integer)
45
- raise ArgumentError,"indent_level must be >= 0" if num < 0
47
+ raise ArgumentError, 'indent_level must be >= 0' if num < 0
46
48
  @indent_level = num
47
49
  end
48
50
 
data/lib/html/foot.rb CHANGED
@@ -1,49 +1,57 @@
1
+ require 'singleton'
2
+
3
+ # The HTML module serves as a namespace only.
1
4
  module HTML
2
5
 
3
- # This class represents an HTML table foot (<tfoot>). It is a
4
- # subclass of Table::TableSection. It is a singleton class.
5
- #
6
- class Table::Foot < Table::TableSection
7
- private_class_method :new
8
-
9
- @@foot = nil
10
- @indent_level = 3
11
- @end_tags = true
12
-
13
- # This is our constructor for Foot objects because it is a singleton
14
- # class. Optionally, a block may be provided. If an argument is
15
- # provided it is treated as content.
16
- #
17
- def self.create(arg=nil, &block)
18
- @@foot = new(arg, &block) unless @@foot
19
- @@foot
20
- end
21
-
22
- # Called by create() instead of new(). This initializes the Foot class.
23
- #
24
- def initialize(arg, &block)
25
- @html_begin = "<tfoot"
26
- @html_end = "</tfoot>"
27
- instance_eval(&block) if block_given?
28
- self.content = arg if arg
29
- end
30
-
31
- # Returns a boolean indicating whether or not end tags, </tfoot>, are
32
- # included for each Foot object in the final HTML output. The
33
- # default is true.
34
- #
35
- def self.end_tags?
36
- @end_tags
37
- end
38
-
39
- # Sets whether or not end tags are included for each Foot object in
40
- # the final HTML output. The default is true. Only true or false are
41
- # valid arguments.
42
- #
43
- def self.end_tags=(bool)
44
- expect(bool, [TrueClass,FalseClass])
45
- @end_tags = bool
46
- end
47
- end
6
+ # This class represents an HTML table foot (<tfoot>). It is a
7
+ # subclass of Table::TableSection. It is a singleton class.
8
+ #
9
+ class Table::Foot < Table::TableSection
10
+ include Singleton
11
+ extend HTML::Mixin::StrongTyping
12
+
13
+ @indent_level = 3
14
+ @end_tags = true
15
+
16
+ # This is our constructor for Foot objects because it is a singleton
17
+ # class. Optionally, a block may be provided. If an argument is
18
+ # provided it is treated as content.
19
+ #
20
+ def self.create(arg = nil, &block)
21
+ instance(arg, &block)
22
+ end
23
+
24
+ # Part of the singleton interface.
25
+ #
26
+ def self.instance(arg = nil, &block)
27
+ @instance ||= new(arg, &block)
28
+ end
29
+
30
+ # Called by create() instead of new(). This initializes the Foot class.
31
+ #
32
+ def initialize(arg, &block)
33
+ @html_begin = '<tfoot'
34
+ @html_end = '</tfoot>'
35
+ super(&block)
36
+ self.content = arg if arg
37
+ end
38
+
39
+ # Returns a boolean indicating whether or not end tags, </tfoot>, are
40
+ # included for each Foot object in the final HTML output. The
41
+ # default is true.
42
+ #
43
+ def self.end_tags?
44
+ @end_tags
45
+ end
46
+
47
+ # Sets whether or not end tags are included for each Foot object in
48
+ # the final HTML output. The default is true. Only true or false are
49
+ # valid arguments.
50
+ #
51
+ def self.end_tags=(bool)
52
+ expect(bool, [TrueClass, FalseClass])
53
+ @end_tags = bool
54
+ end
55
+ end
48
56
 
49
57
  end
data/lib/html/head.rb CHANGED
@@ -1,49 +1,56 @@
1
+ require 'singleton'
2
+
3
+ # The HTML module serves only as a namespace.
1
4
  module HTML
2
-
3
- # This class represents an HTML table head (<thead>). It is a
4
- # subclass of Table::TableSection. It is a singleton class.
5
- #
6
- class Table::Head < Table::TableSection
7
- private_class_method :new
8
-
9
- @@head = nil
10
-
11
- @indent_level = 3
12
- @end_tags = true
13
-
14
- # This is our constructor for Head objects because it is a singleton
15
- # class. Optionally, a block may be provided. If an argument is
16
- # provided it is treated as content.
17
- #
18
- def self.create(arg=nil, &block)
19
- @@head = new(arg, &block) unless @@head
20
- @@head
21
- end
22
-
23
- # Called by create() instead of new(). This initializes the Head class.
24
- #
25
- def initialize(arg, &block)
26
- @html_begin = "<thead"
27
- @html_end = "</thead>"
28
- instance_eval(&block) if block_given?
29
- self.content = arg if arg
30
- end
31
-
32
- # Returns a boolean indicating whether or not end tags, </thead>, are
33
- # included for each Head object in the final HTML output. The
34
- # default is true.
35
- #
36
- def self.end_tags?
37
- @end_tags
38
- end
39
-
40
- # Sets whether or not end tags are included for each Head object in
41
- # the final HTML output. The default is true. Only true or false are
42
- # valid arguments.
43
- #
44
- def self.end_tags=(bool)
45
- expect(bool,[TrueClass,FalseClass])
46
- @end_tags = bool
47
- end
48
- end
5
+
6
+ # This class represents an HTML table head (<thead>). It is a
7
+ # subclass of Table::TableSection. It is a singleton class.
8
+ #
9
+ class Table::Head < Table::TableSection
10
+ include Singleton
11
+ extend HTML::Mixin::StrongTyping
12
+
13
+ @indent_level = 3
14
+ @end_tags = true
15
+
16
+ # This is our constructor for Head objects because it is a singleton
17
+ # class. Optionally, a block may be provided. If an argument is
18
+ # provided it is treated as content.
19
+ #
20
+ def self.create(arg = nil, &block)
21
+ instance(arg, &block)
22
+ end
23
+
24
+ # Part of the singleton interface.
25
+ #
26
+ def self.instance(arg = nil, &block)
27
+ @instance ||= new(arg, &block)
28
+ end
29
+
30
+ # Called by create() instead of new(). This initializes the Head class.
31
+ #
32
+ def initialize(arg, &block)
33
+ @html_begin = '<thead'
34
+ @html_end = '</thead>'
35
+ super(&block)
36
+ self.content = arg if arg
37
+ end
38
+
39
+ # Returns a boolean indicating whether or not end tags, </thead>, are
40
+ # included for each Head object in the final HTML output. The
41
+ # default is true.
42
+ #
43
+ def self.end_tags?
44
+ @end_tags
45
+ end
46
+
47
+ # Sets whether or not end tags are included for each Head object in
48
+ # the final HTML output. The default is true. Only true or false are
49
+ # valid arguments.
50
+ #
51
+ def self.end_tags=(bool)
52
+ expect(bool, [TrueClass, FalseClass])
53
+ @end_tags = bool
54
+ end
55
+ end
49
56
  end
data/lib/html/header.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # The HTML module serves as a namespace only.
1
2
  module HTML
2
3
 
3
4
  # This class represents an HTML table header (<th>). Despite the name
@@ -6,6 +7,7 @@ module HTML
6
7
  class Table::Row::Header
7
8
  include HTML::Mixin::AttributeHandler
8
9
  include HTML::Mixin::HtmlHandler
10
+ extend HTML::Mixin::StrongTyping
9
11
 
10
12
  undef_method :configure
11
13
 
@@ -41,8 +43,8 @@ module HTML
41
43
  # is 6.
42
44
  #
43
45
  def self.indent_level=(num)
44
- expect(num,Integer)
45
- raise ArgumentError,"indent_level must be >= 0" if num < 0
46
+ expect(num, Integer)
47
+ raise ArgumentError, 'indent_level must be >= 0' if num < 0
46
48
  @indent_level = num
47
49
  end
48
50
 
@@ -58,7 +60,7 @@ module HTML
58
60
  # valid arguments.
59
61
  #
60
62
  def self.end_tags=(bool)
61
- expect(bool,[TrueClass,FalseClass])
63
+ expect(bool, [TrueClass, FalseClass])
62
64
  @end_tags = bool
63
65
  end
64
66
  end
@@ -1,11 +1,14 @@
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
- #--
1
+ ##########################################################################
4
2
  # The seemingly redundant writer methods were left here for backwards
5
- # compatibility and for those who may not prefer the DSI.
6
- #
3
+ # compatibility and for those who may not prefer the DSL.
4
+ ##########################################################################
5
+
6
+ # The HTML module serves as a namespace only.
7
7
  module HTML
8
+ # The Mixin module serves as a namespace to prevent collisions.
8
9
  module Mixin
10
+ # The AttributeHandler module creates methods for each of the various attributes
11
+ # associated with HTML tables. In some cases validation is done on the setters.
9
12
  module AttributeHandler
10
13
  def abbr(string = nil)
11
14
  @abbr ||= nil
@@ -15,7 +18,7 @@ module HTML
15
18
 
16
19
  def abbr=(string)
17
20
  @abbr = string
18
- modify_html("abbr", string)
21
+ modify_html('abbr', string)
19
22
  end
20
23
 
21
24
  def align(position = nil)
@@ -25,10 +28,10 @@ module HTML
25
28
  end
26
29
 
27
30
  def align=(position)
28
- valid = %w/top bottom left center right/
31
+ valid = %w[top bottom left center right]
29
32
  raise ArgumentError unless valid.include?(position.downcase)
30
33
  @align = position
31
- modify_html("align", position)
34
+ modify_html('align', position)
32
35
  end
33
36
 
34
37
  def axis(string = nil)
@@ -39,7 +42,7 @@ module HTML
39
42
 
40
43
  def axis=(string)
41
44
  @axis = string
42
- modify_html("axis", string)
45
+ modify_html('axis', string)
43
46
  end
44
47
 
45
48
  def background(url = nil)
@@ -49,11 +52,11 @@ module HTML
49
52
  end
50
53
 
51
54
  def background=(url)
52
- raise TypeError unless url.kind_of?(String)
53
- msg = "'background' is a non-standard extension"
55
+ raise TypeError unless url.is_a?(String)
56
+ msg = "'background' is a non-standard extension"
54
57
  warn NonStandardExtensionWarning, msg
55
58
  @background = url
56
- modify_html("background", url)
59
+ modify_html('background', url)
57
60
  end
58
61
 
59
62
  def bgcolor(color = nil)
@@ -64,7 +67,7 @@ module HTML
64
67
 
65
68
  def bgcolor=(color)
66
69
  @bgcolor = color
67
- modify_html("bgcolor", color)
70
+ modify_html('bgcolor', color)
68
71
  end
69
72
 
70
73
  def border(num = nil)
@@ -75,13 +78,14 @@ module HTML
75
78
 
76
79
  # Allow either true/false or an integer
77
80
  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)
81
+ case num
82
+ when TrueClass
83
+ modify_html('border', true)
84
+ when FalseClass
85
+ # Do nothing
86
+ else
87
+ @border = num.to_i
88
+ modify_html('border', num.to_i)
85
89
  end
86
90
  end
87
91
 
@@ -93,9 +97,9 @@ module HTML
93
97
 
94
98
  def bordercolor=(color)
95
99
  @bordercolor = color
96
- msg = "'bordercolor' is a non-standard extension"
100
+ msg = "'bordercolor' is a non-standard extension"
97
101
  warn NonStandardExtensionWarning, msg
98
- modify_html("bordercolor", color)
102
+ modify_html('bordercolor', color)
99
103
  end
100
104
 
101
105
  def bordercolordark(color = nil)
@@ -108,7 +112,7 @@ module HTML
108
112
  @bordercolordark = color
109
113
  msg = "'bordercolordark' is a non-standard extension"
110
114
  warn NonStandardExtensionWarning, msg
111
- modify_html("bordercolordark", color)
115
+ modify_html('bordercolordark', color)
112
116
  end
113
117
 
114
118
  def bordercolorlight(color = nil)
@@ -121,7 +125,7 @@ module HTML
121
125
  @bordercolorlight = color
122
126
  msg = "'bordercolorlight' is a non-standard extension"
123
127
  warn NonStandardExtensionWarning, msg
124
- modify_html("bordercolorlight", @bordercolorlight)
128
+ modify_html('bordercolorlight', @bordercolorlight)
125
129
  end
126
130
 
127
131
  def cellpadding(num = nil)
@@ -133,7 +137,7 @@ module HTML
133
137
  def cellpadding=(num)
134
138
  raise ArgumentError if num.to_i < 0
135
139
  @cellpadding = num.to_i
136
- modify_html("cellpadding", @cellpadding)
140
+ modify_html('cellpadding', @cellpadding)
137
141
  end
138
142
 
139
143
  def cellspacing(num = nil)
@@ -145,7 +149,7 @@ module HTML
145
149
  def cellspacing=(num)
146
150
  raise ArgumentError if num.to_i < 0
147
151
  @cellspacing = num.to_i
148
- modify_html("cellspacing", @cellspacing)
152
+ modify_html('cellspacing', @cellspacing)
149
153
  end
150
154
 
151
155
  def char(character = nil)
@@ -157,7 +161,7 @@ module HTML
157
161
  def char=(character)
158
162
  raise ArgumentError if character.to_s.length > 1
159
163
  @char = character.to_s
160
- modify_html("char", character.to_s)
164
+ modify_html('char', character.to_s)
161
165
  end
162
166
 
163
167
  def charoff(offset = nil)
@@ -169,7 +173,7 @@ module HTML
169
173
  def charoff=(offset)
170
174
  raise ArgumentError if offset.to_i < 0
171
175
  @charoff = offset
172
- modify_html("charoff", offset)
176
+ modify_html('charoff', offset)
173
177
  end
174
178
 
175
179
  # Returns the CSS class. The trailing underscore is necessary in order
@@ -198,7 +202,7 @@ module HTML
198
202
  def col=(num)
199
203
  raise ArgumentError if num.to_i < 0
200
204
  @col = num.to_i
201
- modify_html("col", @col)
205
+ modify_html('col', @col)
202
206
  end
203
207
 
204
208
  def colspan(span = nil)
@@ -210,17 +214,17 @@ module HTML
210
214
  def colspan=(span)
211
215
  raise ArgumentError if span.to_i < 0
212
216
  @colspan = span.to_i
213
- modify_html("colspan", @colspan)
217
+ modify_html('colspan', @colspan)
214
218
  end
215
219
 
216
220
  # Allows you to configure various attributes by row or row + column.
217
221
  #
218
- def configure(row, col=nil, &block)
222
+ def configure(row, col = nil)
219
223
  if col
220
224
  begin
221
225
  yield self[row][col]
222
226
  rescue NameError
223
- msg = "No column to configure in a " + self.class.to_s + " class"
227
+ msg = "No column to configure in a #{self.class} class"
224
228
  raise ArgumentError, msg
225
229
  end
226
230
  else
@@ -235,15 +239,15 @@ module HTML
235
239
  when String
236
240
  self.content = Table::Content.new(arg, &block)
237
241
  when Array
238
- arg.each{ |e|
239
- if e.kind_of?(Array)
242
+ arg.each do |e|
243
+ if e.is_a?(Array)
240
244
  row = Table::Row.new
241
- e.each{ |element| row.push(Table::Content.new(element, &block)) }
242
- self.push(row)
245
+ e.each { |element| row.push(Table::Content.new(element, &block)) }
246
+ push(row)
243
247
  else
244
248
  self.content = Table::Content.new(e, &block)
245
249
  end
246
- }
250
+ end
247
251
  else
248
252
  self.content = arg if arg
249
253
  end
@@ -259,10 +263,10 @@ module HTML
259
263
  end
260
264
 
261
265
  def frame=(type)
262
- valid = %w/border void above below hsides lhs rhs vsides box/
266
+ valid = %w[border void above below hsides lhs rhs vsides box]
263
267
  raise ArgumentError unless valid.include?(type.downcase)
264
268
  @frame = type
265
- modify_html("frame", @frame)
269
+ modify_html('frame', @frame)
266
270
  end
267
271
 
268
272
  def height(num = nil)
@@ -274,7 +278,7 @@ module HTML
274
278
  def height=(num)
275
279
  raise ArgumentError if num.to_i < 0
276
280
  @height = num.to_i
277
- modify_html("height", @height)
281
+ modify_html('height', @height)
278
282
  end
279
283
 
280
284
  def hspace(num = nil)
@@ -286,7 +290,7 @@ module HTML
286
290
  def hspace=(num)
287
291
  raise ArgumentError if num.to_i < 0
288
292
  @hspace = num.to_i
289
- modify_html("hspace", @hspace)
293
+ modify_html('hspace', @hspace)
290
294
  end
291
295
 
292
296
  def nowrap(bool = nil)
@@ -296,11 +300,11 @@ module HTML
296
300
  end
297
301
 
298
302
  def nowrap=(bool)
299
- unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass)
300
- raise TypeError
303
+ unless bool.is_a?(TrueClass) || bool.is_a?(FalseClass)
304
+ raise TypeError
301
305
  end
302
306
  @nowrap = bool
303
- modify_html("nowrap", @nowrap)
307
+ modify_html('nowrap', @nowrap)
304
308
  end
305
309
 
306
310
  def rowspan(num = nil)
@@ -312,7 +316,7 @@ module HTML
312
316
  def rowspan=(num)
313
317
  raise ArgumentError if num.to_i < 0
314
318
  @rowspan = num.to_i
315
- modify_html("rowspan", @rowspan)
319
+ modify_html('rowspan', @rowspan)
316
320
  end
317
321
 
318
322
  def rules(edges = nil)
@@ -322,10 +326,10 @@ module HTML
322
326
  end
323
327
 
324
328
  def rules=(edges)
325
- valid = %w/all groups rows cols none/
329
+ valid = %w[all groups rows cols none]
326
330
  raise ArgumentError unless valid.include?(edges.to_s.downcase)
327
331
  @rules = edges
328
- modify_html("rules", @rules)
332
+ modify_html('rules', @rules)
329
333
  end
330
334
 
331
335
  def span(num = nil)
@@ -337,7 +341,7 @@ module HTML
337
341
  def span=(num)
338
342
  raise ArgumentError if num.to_i < 0
339
343
  @span = num.to_i
340
- modify_html("span", @span)
344
+ modify_html('span', @span)
341
345
  end
342
346
 
343
347
  def style(string = nil)
@@ -348,7 +352,7 @@ module HTML
348
352
 
349
353
  def style=(string)
350
354
  @style = string.to_s
351
- modify_html("style", @style)
355
+ modify_html('style', @style)
352
356
  end
353
357
 
354
358
  def summary(string = nil)
@@ -359,7 +363,7 @@ module HTML
359
363
 
360
364
  def summary=(string)
361
365
  @summary = string.to_s
362
- modify_html("summary", @summary)
366
+ modify_html('summary', @summary)
363
367
  end
364
368
 
365
369
  def valign(position = nil)
@@ -369,10 +373,10 @@ module HTML
369
373
  end
370
374
 
371
375
  def valign=(position)
372
- valid = %w/top center bottom baseline/
376
+ valid = %w[top center bottom baseline]
373
377
  raise ArgumentError unless valid.include?(position.to_s.downcase)
374
378
  @valign = position
375
- modify_html("valign", @valign)
379
+ modify_html('valign', @valign)
376
380
  end
377
381
 
378
382
  def vspace(num = nil)
@@ -384,7 +388,7 @@ module HTML
384
388
  def vspace=(num)
385
389
  raise ArgumentError if num.to_i < 0
386
390
  @vspace = num.to_i
387
- modify_html("vspace", @vspace)
391
+ modify_html('vspace', @vspace)
388
392
  end
389
393
 
390
394
  def width(num = nil)
@@ -394,13 +398,13 @@ module HTML
394
398
  end
395
399
 
396
400
  def width=(num)
397
- if num =~ /%/
401
+ if num.to_s =~ /%/
398
402
  @width = num
399
403
  else
400
404
  raise ArgumentError if num.to_i < 0
401
405
  @width = num.to_i
402
406
  end
403
- modify_html("width", @width)
407
+ modify_html('width', @width)
404
408
  end
405
409
  end
406
410
  end