htmlgrid 1.1.7 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/htmlgrid/booleanvalue.rb +14 -14
  3. data/lib/htmlgrid/button.rb +9 -9
  4. data/lib/htmlgrid/centeredcomposite.rb +21 -20
  5. data/lib/htmlgrid/component.rb +214 -197
  6. data/lib/htmlgrid/composite.rb +332 -301
  7. data/lib/htmlgrid/datevalue.rb +12 -12
  8. data/lib/htmlgrid/div.rb +9 -9
  9. data/lib/htmlgrid/divcomposite.rb +44 -43
  10. data/lib/htmlgrid/divform.rb +8 -8
  11. data/lib/htmlgrid/divlist.rb +17 -19
  12. data/lib/htmlgrid/divtemplate.rb +6 -6
  13. data/lib/htmlgrid/dojotoolkit.rb +54 -48
  14. data/lib/htmlgrid/errormessage.rb +47 -43
  15. data/lib/htmlgrid/form.rb +70 -62
  16. data/lib/htmlgrid/formlist.rb +14 -14
  17. data/lib/htmlgrid/grid.rb +111 -67
  18. data/lib/htmlgrid/image.rb +17 -16
  19. data/lib/htmlgrid/infomessage.rb +15 -14
  20. data/lib/htmlgrid/input.rb +34 -32
  21. data/lib/htmlgrid/inputcheckbox.rb +13 -13
  22. data/lib/htmlgrid/inputcurrency.rb +9 -9
  23. data/lib/htmlgrid/inputdate.rb +11 -11
  24. data/lib/htmlgrid/inputfile.rb +13 -12
  25. data/lib/htmlgrid/inputradio.rb +9 -9
  26. data/lib/htmlgrid/inputtext.rb +10 -10
  27. data/lib/htmlgrid/javascript.rb +17 -16
  28. data/lib/htmlgrid/label.rb +53 -49
  29. data/lib/htmlgrid/labeltext.rb +8 -8
  30. data/lib/htmlgrid/link.rb +31 -27
  31. data/lib/htmlgrid/list.rb +121 -110
  32. data/lib/htmlgrid/namedcomponent.rb +28 -25
  33. data/lib/htmlgrid/pass.rb +11 -11
  34. data/lib/htmlgrid/passthru.rb +20 -17
  35. data/lib/htmlgrid/popuplink.rb +41 -39
  36. data/lib/htmlgrid/reset.rb +8 -8
  37. data/lib/htmlgrid/richtext.rb +22 -20
  38. data/lib/htmlgrid/select.rb +28 -26
  39. data/lib/htmlgrid/span.rb +9 -9
  40. data/lib/htmlgrid/spancomposite.rb +18 -18
  41. data/lib/htmlgrid/spanlist.rb +9 -9
  42. data/lib/htmlgrid/staticinput.rb +14 -13
  43. data/lib/htmlgrid/submit.rb +9 -9
  44. data/lib/htmlgrid/template.rb +121 -105
  45. data/lib/htmlgrid/text.rb +9 -9
  46. data/lib/htmlgrid/textarea.rb +19 -17
  47. data/lib/htmlgrid/ulcomposite.rb +22 -22
  48. data/lib/htmlgrid/ullist.rb +9 -9
  49. data/lib/htmlgrid/urllink.rb +38 -36
  50. data/lib/htmlgrid/value.rb +9 -9
  51. data/lib/htmlgrid/version.rb +2 -2
  52. data/test/stub/cgi.rb +10 -7
  53. data/test/suite.rb +3 -3
  54. data/test/test_add_row.rb +12 -13
  55. data/test/test_component.rb +141 -91
  56. data/test/test_composite.rb +85 -46
  57. data/test/test_datevalue.rb +28 -24
  58. data/test/test_divlist.rb +126 -0
  59. data/test/test_dojotoolkit.rb +41 -26
  60. data/test/test_form.rb +89 -73
  61. data/test/test_formlist.rb +77 -65
  62. data/test/test_grid.rb +256 -208
  63. data/test/test_input.rb +37 -31
  64. data/test/test_interaction_list.rb +106 -70
  65. data/test/test_label.rb +91 -77
  66. data/test/test_list.rb +110 -95
  67. data/test/test_select.rb +35 -30
  68. data/test/test_template.rb +66 -55
  69. data/test/test_text.rb +36 -31
  70. metadata +17 -4
  71. data/TooltipDialog.txt +0 -73
  72. data/interaction_no_inline.txt +0 -1216
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -25,46 +25,50 @@
25
25
  # ErrorMessage -- htmlgrid -- 10.04.2003 -- benfay@ywesee.com
26
26
 
27
27
  module HtmlGrid
28
- module ErrorMessage
29
- private
30
- def error_message(ypos = 0)
31
- @displayed_messages = []
32
- if(@session.warning?)
33
- __messages(@session.warnings, 'warning', ypos)
34
- end
35
- if(@session.error?)
36
- __messages(@session.errors, 'processingerror', ypos)
37
- end
38
- end
39
- def error_text(obj)
40
- message = obj.message
41
- txt = HtmlGrid::Text.new(message, @model, @session, self)
42
- if(txt.value.nil?)
43
- txt.value = @lookandfeel.lookup(message, escape(obj.value))
44
- end
45
- if(txt.value.nil? && (match = /^(._[^_]+)_(.*)$/.match(message.to_s)) \
46
- && (label = @lookandfeel.lookup(match[2])))
47
- txt.value = @lookandfeel.lookup(match[1], label)
48
- end
49
- txt
50
- end
51
- def __message(obj, css_class, ypos=0)
52
- @displayed_messages ||= []
53
- message = obj.message
54
- unless(@displayed_messages.include?(message))
55
- @displayed_messages.push(message)
56
- txt = error_text(obj)
57
- unless(txt.value.nil?)
58
- insert_row(ypos, txt, css_class)
59
- end
60
- end
61
- end
62
- def __messages(ary, css_class, ypos=0)
63
- ary.sort_by { |item|
64
- (components.key(item.key) || [-1,-1]).reverse
65
- }.reverse.each { |item|
66
- __message(item, css_class, ypos)
67
- }
68
- end
69
- end
28
+ module ErrorMessage
29
+ private
30
+
31
+ def error_message(ypos = 0)
32
+ @displayed_messages = []
33
+ if @session.warning?
34
+ __messages(@session.warnings, "warning", ypos)
35
+ end
36
+ if @session.error?
37
+ __messages(@session.errors, "processingerror", ypos)
38
+ end
39
+ end
40
+
41
+ def error_text(obj)
42
+ message = obj.message
43
+ txt = HtmlGrid::Text.new(message, @model, @session, self)
44
+ if txt.value.nil?
45
+ txt.value = @lookandfeel.lookup(message, escape(obj.value))
46
+ end
47
+ if txt.value.nil? && (match = /^(._[^_]+)_(.*)$/.match(message.to_s)) \
48
+ && (label = @lookandfeel.lookup(match[2]))
49
+ txt.value = @lookandfeel.lookup(match[1], label)
50
+ end
51
+ txt
52
+ end
53
+
54
+ def __message(obj, css_class, ypos = 0)
55
+ @displayed_messages ||= []
56
+ message = obj.message
57
+ unless @displayed_messages.include?(message)
58
+ @displayed_messages.push(message)
59
+ txt = error_text(obj)
60
+ unless txt.value.nil?
61
+ insert_row(ypos, txt, css_class)
62
+ end
63
+ end
64
+ end
65
+
66
+ def __messages(ary, css_class, ypos = 0)
67
+ ary.sort_by { |item|
68
+ (components.key(item.key) || [-1, -1]).reverse
69
+ }.reverse_each { |item|
70
+ __message(item, css_class, ypos)
71
+ }
72
+ end
73
+ end
70
74
  end
data/lib/htmlgrid/form.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -22,68 +22,76 @@
22
22
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
23
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
24
  #
25
- # Form -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
25
+ # Form -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/composite'
28
- require 'htmlgrid/submit'
27
+ require "htmlgrid/composite"
28
+ require "htmlgrid/submit"
29
29
 
30
30
  module HtmlGrid
31
- module FormMethods
32
- AUTOFILL = false
33
- ACCEPT_CHARSET = 'UTF-8'
34
- EVENT = nil
35
- FORM_ACTION = nil
36
- FORM_METHOD = 'POST'
37
- FORM_NAME = 'stdform'
38
- TAG_METHOD = :form
39
- def autofill?
40
- self.class.const_get(:AUTOFILL)
41
- end
42
- def event
43
- self::class::EVENT
44
- end
45
- def formname
46
- if(defined? self::class::FORM_NAME)
47
- self::class::FORM_NAME
48
- end
49
- end
50
- def onsubmit=(onsubmit)
51
- @form_properties["onSubmit"] = onsubmit
52
- end
53
- def to_html(context)
54
- context.send(self::class::TAG_METHOD, @form_properties) {
55
- super << context.div('style'=>'display:none') { hidden_fields(context) }
56
- }
57
- end
58
- private
59
- def hidden_fields(context)
60
- '' <<
61
- context.hidden('flavor', @lookandfeel.flavor) <<
62
- context.hidden('language', @lookandfeel.language) <<
63
- context.hidden({'NAME' => 'event', 'ID' => 'event',
64
- 'VALUE' => event.to_s}) <<
65
- context.hidden('state_id', @session.state.object_id.to_s)
66
- end
67
- def init
68
- @form_properties = {}
69
- if(defined? self::class::FORM_CSS_CLASS)
70
- @form_properties.store('class', self::class::FORM_CSS_CLASS)
71
- end
72
- if(defined? self::class::FORM_NAME)
73
- @form_properties.store('NAME', self::class::FORM_NAME)
74
- end
75
- if(defined? self::class::FORM_ID)
76
- @form_properties.store('ID', self::class::FORM_ID)
77
- end
78
- super
79
- @form_properties.update({
80
- 'METHOD' => self::class::FORM_METHOD.dup,
81
- 'ACTION' => (self::class::FORM_ACTION || @lookandfeel.base_url),
82
- 'ACCEPT-CHARSET' => self::class::ACCEPT_CHARSET,
83
- })
84
- end
85
- end
86
- class Form < Composite
87
- include FormMethods
88
- end
31
+ module FormMethods
32
+ AUTOFILL = false
33
+ ACCEPT_CHARSET = "UTF-8"
34
+ EVENT = nil
35
+ FORM_ACTION = nil
36
+ FORM_METHOD = "POST"
37
+ FORM_NAME = "stdform"
38
+ TAG_METHOD = :form
39
+ def autofill?
40
+ self.class.const_get(:AUTOFILL)
41
+ end
42
+
43
+ def event
44
+ self.class::EVENT
45
+ end
46
+
47
+ def formname
48
+ if defined? self.class::FORM_NAME
49
+ self.class::FORM_NAME
50
+ end
51
+ end
52
+
53
+ def onsubmit=(onsubmit)
54
+ @form_properties["onSubmit"] = onsubmit
55
+ end
56
+
57
+ def to_html(context)
58
+ context.send(self.class::TAG_METHOD, @form_properties) {
59
+ super << context.div("style" => "display:none") { hidden_fields(context) }
60
+ }
61
+ end
62
+
63
+ private
64
+
65
+ def hidden_fields(context)
66
+ "" <<
67
+ context.hidden("flavor", @lookandfeel.flavor) <<
68
+ context.hidden("language", @lookandfeel.language) <<
69
+ context.hidden({"NAME" => "event", "ID" => "event",
70
+ "VALUE" => event.to_s}) <<
71
+ context.hidden("state_id", @session.state.object_id.to_s)
72
+ end
73
+
74
+ def init
75
+ @form_properties = {}
76
+ if defined? self.class::FORM_CSS_CLASS
77
+ @form_properties.store("class", self.class::FORM_CSS_CLASS)
78
+ end
79
+ if defined? self.class::FORM_NAME
80
+ @form_properties.store("NAME", self.class::FORM_NAME)
81
+ end
82
+ if defined? self.class::FORM_ID
83
+ @form_properties.store("ID", self.class::FORM_ID)
84
+ end
85
+ super
86
+ @form_properties.update({
87
+ "METHOD" => self.class::FORM_METHOD.dup,
88
+ "ACTION" => (self.class::FORM_ACTION || @lookandfeel.base_url),
89
+ "ACCEPT-CHARSET" => self.class::ACCEPT_CHARSET
90
+ })
91
+ end
92
+ end
93
+
94
+ class Form < Composite
95
+ include FormMethods
96
+ end
89
97
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -24,19 +24,19 @@
24
24
  #
25
25
  # FormList -- htmlgrid -- 25.03.2003 -- aschrafl@ywesee.com
26
26
 
27
- require 'htmlgrid/list'
28
- require 'htmlgrid/form'
29
- require 'htmlgrid/value'
30
- require 'htmlgrid/button'
27
+ require "htmlgrid/list"
28
+ require "htmlgrid/form"
29
+ require "htmlgrid/value"
30
+ require "htmlgrid/button"
31
31
 
32
32
  module HtmlGrid
33
- class FormList < List
34
- include FormMethods
35
- DEFAULT_CLASS = Value
36
- EVENT = :new_item
37
- def compose_footer(matrix)
38
- @grid.add(submit(), *matrix)
39
- @grid.set_colspan(*matrix)
40
- end
41
- end
33
+ class FormList < List
34
+ include FormMethods
35
+ DEFAULT_CLASS = Value
36
+ EVENT = :new_item
37
+ def compose_footer(matrix)
38
+ @grid.add(submit, *matrix)
39
+ @grid.set_colspan(*matrix)
40
+ end
41
+ end
42
42
  end
data/lib/htmlgrid/grid.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -27,118 +27,141 @@
27
27
  module HtmlGrid
28
28
  class Grid
29
29
  attr_accessor :width, :height
30
+
30
31
  private
32
+
31
33
  class Row
32
34
  class Field
33
35
  attr_reader :components, :tag
34
36
  ALLOWED_ATTRIBUTES = [
35
- 'align',
36
- 'class',
37
- 'colspan',
38
- 'style',
39
- 'tag',
40
- 'title',
37
+ "align",
38
+ "class",
39
+ "colspan",
40
+ "style",
41
+ "tag",
42
+ "title"
41
43
  ]
42
44
  def initialize
43
45
  @components = []
44
46
  @attributes = {}
45
47
  @tag = nil
46
48
  end
49
+
47
50
  def add(item)
48
- if(item.is_a? Array)
51
+ if item.is_a? Array
49
52
  @components += item
50
53
  else
51
54
  @components.push item
52
55
  end
53
56
  end
57
+
54
58
  def add_background
55
59
  compose
56
- @components.each { |component|
60
+ @components.each { |component|
57
61
  component.add_background
58
62
  }
59
- if(@attributes["class"])
60
- @attributes["class"] += "-bg" unless @attributes["class"] =~ /-bg/
63
+ if @attributes["class"]
64
+ @attributes["class"] += "-bg" unless /-bg/.match?(@attributes["class"])
61
65
  else
62
66
  @attributes["class"] = "bg"
63
67
  end
64
68
  end
69
+
65
70
  def add_attribute(key, value)
66
71
  @attributes.store(key.to_s, value.to_s)
67
72
  end
73
+
68
74
  def add_component_style(style)
69
- @components.each { |cmp|
75
+ @components.each { |cmp|
70
76
  cmp.set_attribute("class", style) if cmp.respond_to?(:set_attribute)
71
77
  }
72
78
  end
79
+
73
80
  def add_style(style)
74
81
  @attributes["class"] = style
75
82
  end
83
+
76
84
  def attribute(key)
77
85
  @attributes[key]
78
86
  end
87
+
79
88
  def colspan
80
89
  @attributes.fetch("colspan", 1).to_i
81
90
  end
91
+
82
92
  def colspan=(span)
83
93
  @attributes["colspan"] = span.to_s if span.to_i > 1
84
94
  end
95
+
85
96
  def component_html(cgi)
86
- html = ''
97
+ html = ""
87
98
  @components.each { |component|
88
- if component.respond_to? :to_html
89
- html << component.to_html(cgi).to_s.dup.force_encoding('utf-8')
99
+ html << if component.respond_to? :to_html
100
+ component.to_html(cgi).to_s.dup.force_encoding("utf-8")
90
101
  else
91
- html << component.to_s
102
+ component.to_s
92
103
  end
93
104
  }
94
105
  html = "&nbsp;" if html.empty?
95
106
  html
96
107
  end
108
+
97
109
  def tag=(tag)
98
110
  @tag = tag.to_s.downcase
99
111
  end
112
+
100
113
  def to_html(context)
101
- if(@tag && context.respond_to?(@tag))
102
- context.send(@tag, @attributes) {
103
- component_html(context) }
114
+ if @tag && context.respond_to?(@tag)
115
+ context.send(@tag, @attributes) {
116
+ component_html(context)
117
+ }
104
118
  else
105
119
  context.td(@attributes) {
106
- component_html(context) }
120
+ component_html(context)
121
+ }
107
122
  end
108
123
  end
109
124
  end
110
- def initialize # Row
125
+
126
+ # Row
127
+ def initialize
111
128
  @width = 1
112
129
  @fields = [Field.new]
113
130
  @attributes = {}
114
131
  end
132
+
115
133
  def initialize_row w
116
- if(w > @width)
117
- @width.upto(w-1) { |ii| @fields[ii] ||= Field.new }
134
+ if w > @width
135
+ @width.upto(w - 1) { |ii| @fields[ii] ||= Field.new }
118
136
  @width = w
119
137
  end
120
138
  end
139
+
121
140
  def add(item, x)
122
141
  (@fields[x] ||= Field.new).add item
123
142
  end
124
- def each_field(x, w=1)
125
- x.upto([x+w, @width].min - 1) { |xx|
143
+
144
+ def each_field(x, w = 1)
145
+ x.upto([x + w, @width].min - 1) { |xx|
126
146
  yield(@fields[xx])
127
147
  }
128
148
  end
149
+
129
150
  def to_html cgi
130
151
  cgi.tr(@attributes) {
131
152
  field_html(cgi)
132
153
  }
133
154
  end
134
- def field_attribute(key, x=0)
155
+
156
+ def field_attribute(key, x = 0)
135
157
  @fields[x].attribute(key)
136
158
  end
159
+
137
160
  def field_html(cgi)
138
161
  html = ""
139
162
  span = 1
140
163
  @fields.each { |field|
141
- if(span < 2)
164
+ if span < 2
142
165
  html << field.to_html(cgi)
143
166
  span = field.colspan
144
167
  else
@@ -147,29 +170,33 @@ module HtmlGrid
147
170
  }
148
171
  html
149
172
  end
173
+
150
174
  def set_attributes(attr)
151
175
  @attributes = attr
152
176
  end
177
+
153
178
  def [](x)
154
- begin
155
- @fields[x]
156
- rescue StandardError
157
- nil
158
- end
179
+ @fields[x]
180
+ rescue
181
+ nil
159
182
  end
160
183
  end
184
+
161
185
  public
162
- def initialize(attributes={}) # Grid
186
+
187
+ # Grid
188
+ def initialize(attributes = {})
163
189
  @height = 1
164
190
  @width = 1
165
191
  @rows = [Row.new]
166
192
  @attributes = {
167
- "cellspacing" => "0",
193
+ "cellspacing" => "0"
168
194
  }.update(attributes)
169
195
  end
196
+
170
197
  def initialize_grid(w, h)
171
- if(w > @width || h > @height)
172
- floor = (w > @width) ? 0 : @height
198
+ if w > @width || h > @height
199
+ floor = w > @width ? 0 : @height
173
200
  @width = [w, @width].max
174
201
  @height = [h, @height].max
175
202
  floor.upto(@height - 1) { |ii|
@@ -177,13 +204,14 @@ module HtmlGrid
177
204
  }
178
205
  end
179
206
  end
180
- def add(arg, x, y, col=false)
181
- if arg.kind_of?(Enumerable)
182
- if arg.kind_of?(String)
207
+
208
+ def add(arg, x, y, col = false)
209
+ if arg.is_a?(Enumerable)
210
+ if arg.is_a?(String)
183
211
  add_field(arg, x, y)
184
- elsif arg.kind_of?(Array)
212
+ elsif arg.is_a?(Array)
185
213
  arg.each do |item|
186
- add_field(item, x ? x : '', y)
214
+ add_field(item, x || "", y)
187
215
  end
188
216
  elsif col
189
217
  add_column(arg, x, y)
@@ -194,16 +222,19 @@ module HtmlGrid
194
222
  add_field(arg, x, y)
195
223
  end
196
224
  end
197
- def add_attribute(key, value, x, y, w=1, h=1)
225
+
226
+ def add_attribute(key, value, x, y, w = 1, h = 1)
198
227
  each_field(x, y, w, h) { |field|
199
228
  field.add_attribute(key, value)
200
229
  }
201
230
  end
202
- def add_background(x, y, w=1, h=1)
231
+
232
+ def add_background(x, y, w = 1, h = 1)
203
233
  each_field(x, y, w, h) { |field|
204
234
  field.add_background(x, w)
205
235
  }
206
236
  end
237
+
207
238
  def add_column(arg, x, y)
208
239
  offset = 0
209
240
  arg.each do |item|
@@ -211,15 +242,18 @@ module HtmlGrid
211
242
  offset = offset.next
212
243
  end
213
244
  end
214
- def add_component_style(style, x, y, w=1, h=1)
245
+
246
+ def add_component_style(style, x, y, w = 1, h = 1)
215
247
  each_field(x, y, w, h) { |field|
216
248
  field.add_component_style(style)
217
249
  }
218
250
  end
251
+
219
252
  def add_field(arg, x, y)
220
- initialize_grid(x+1, y+1)
253
+ initialize_grid(x + 1, y + 1)
221
254
  (@rows[y] ||= Row.new).add(arg, x)
222
255
  end
256
+
223
257
  def add_row(arg, x, y)
224
258
  offset = 0
225
259
  arg.each do |item|
@@ -227,65 +261,75 @@ module HtmlGrid
227
261
  offset = offset.next
228
262
  end
229
263
  end
230
- def add_style(style, x, y, w=1, h=1)
264
+
265
+ def add_style(style, x, y, w = 1, h = 1)
231
266
  each_field(x, y, w, h) { |field|
232
267
  field.add_style(style)
233
268
  }
234
269
  end
235
- def add_tag(tag, x, y, w=1, h=1)
236
- initialize_grid(x+w, y+h)
237
- each_field(x, y, w, h) { |field|
270
+
271
+ def add_tag(tag, x, y, w = 1, h = 1)
272
+ initialize_grid(x + w, y + h)
273
+ each_field(x, y, w, h) { |field|
238
274
  field.tag = tag
239
275
  }
240
276
  end
241
- def each_field(x, y, w=1, h=1)
242
- y.upto([y+h, @height].min - 1) { |yy|
243
- @rows[yy].each_field(x,w) { |field|
277
+
278
+ def each_field(x, y, w = 1, h = 1)
279
+ y.upto([y + h, @height].min - 1) { |yy|
280
+ @rows[yy].each_field(x, w) { |field|
244
281
  yield(field)
245
282
  }
246
283
  }
247
284
  end
248
- def field_attribute(key, x=0, y=0)
285
+
286
+ def field_attribute(key, x = 0, y = 0)
249
287
  @rows[y].field_attribute(key, x)
250
288
  end
251
- def insert_row(y=0, arg=nil)
252
- @rows[y, 0] = Row.new
289
+
290
+ def insert_row(y = 0, arg = nil)
291
+ @rows[y, 0] = Row.new
253
292
  @height += 1
254
293
  add(arg, 0, y)
255
294
  end
256
- def push(arg, x=0, y=height)
295
+
296
+ def push(arg, x = 0, y = height)
257
297
  add(arg, x, y)
258
- set_colspan(x,y)
298
+ set_colspan(x, y)
259
299
  end
300
+
260
301
  def set_attribute(key, value)
261
302
  @attributes[key] = value
262
303
  end
304
+
263
305
  def set_attributes(hash)
264
306
  @attributes.update(hash)
265
307
  end
266
- def set_colspan(x=0, y=0, span=(@width - x))
308
+
309
+ def set_colspan(x = 0, y = 0, span = (@width - x))
267
310
  span = span.to_i
268
- initialize_grid(x+span, y+1)
269
- self[x,y].colspan = span
311
+ initialize_grid(x + span, y + 1)
312
+ self[x, y].colspan = span
270
313
  end
271
- def set_row_attributes(attr={}, y=0, offset=0)
314
+
315
+ def set_row_attributes(attr = {}, y = 0, offset = 0)
272
316
  # TODO
273
317
  # At the moment, offset value is not used
274
318
  # But probably offset value is used in grid.c
275
319
  initialize_grid(offset, y + 1)
276
320
  @rows[y].set_attributes(attr)
277
321
  end
322
+
278
323
  def to_html(cgi)
279
324
  cgi.table(@attributes) {
280
- @rows.collect { |row| row.to_html(cgi).force_encoding('utf-8') }.join
325
+ @rows.collect { |row| row.to_html(cgi).force_encoding("utf-8") }.join
281
326
  }
282
327
  end
328
+
283
329
  def [](x, y)
284
- begin
285
- @rows[y][x]
286
- rescue StandardError
287
- nil
288
- end
330
+ @rows[y][x]
331
+ rescue
332
+ nil
289
333
  end
290
334
  end
291
335
  end