Class: WebUnit::SelectOption
Instance Attribute Summary collapse
Attributes inherited from HtmlElem
#array, #attrs, #children, #data, #name, #tag
Instance Method Summary
collapse
Methods inherited from HtmlElem
#append, #extract, #find, #has?, #inspect, #print, #readlink, #search
Constructor Details
Returns a new instance of SelectOption.
229
230
231
232
233
234
|
# File 'lib/webunit/params.rb', line 229
def initialize( ah )
super( 'option', ah )
@value = ah["value"]
@stat = ah.key?( 'selected' ) ? 'on' : 'off'
@type = 'option'
end
|
Instance Attribute Details
Returns the value of attribute stat.
227
228
229
|
# File 'lib/webunit/params.rb', line 227
def stat
@stat
end
|
Instance Method Details
244
245
246
|
# File 'lib/webunit/params.rb', line 244
def deselect
@stat = 'off'
end
|
#multipart_query_data(boundary, name) ⇒ Object
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/webunit/params.rb', line 254
def multipart_query_data( boundary, name)
@value = @data unless @value
value = @value ? @value : ''
if @stat == 'on' and name
"--#{boundary}\n" +
%!Content-Disposition: form-data; name="#{CGI::escape(name)}"\n! +
"\n" +
value + "\n"
else
nil
end
end
|
#query_data(name) ⇒ Object
248
249
250
251
252
|
# File 'lib/webunit/params.rb', line 248
def query_data( name )
@value = @data unless @value
value = @value ? CGI::escape( @value ) : ''
(@stat == 'on' and name) ? name + '=' + value : nil
end
|
240
241
242
|
# File 'lib/webunit/params.rb', line 240
def select
@stat = 'on'
end
|
236
237
238
|
# File 'lib/webunit/params.rb', line 236
def value
@value ? @value : @data
end
|