Class: WebUnit::Param
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
-
#stat ⇒ Object
Returns the value of attribute stat.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from HtmlElem
#array, #attrs, #children, #data, #tag
Instance Method Summary collapse
-
#initialize(tag, ah) ⇒ Param
constructor
A new instance of Param.
- #multipart_query_data(boundary) ⇒ Object
- #query_data ⇒ Object
- #update(p) ⇒ Object
Methods inherited from HtmlElem
#append, #extract, #find, #has?, #inspect, #print, #readlink, #search
Constructor Details
#initialize(tag, ah) ⇒ Param
Returns a new instance of Param.
14 15 16 17 18 19 20 |
# File 'lib/webunit/params.rb', line 14 def initialize( tag, ah ) super @type = ah["type"] ? ah["type"] : 'text' @value = ah["value"] @relations = [] @stat = ah.key?( 'checked' ) ? 'on' : 'off' end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/webunit/params.rb', line 11 def name @name end |
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
11 12 13 |
# File 'lib/webunit/params.rb', line 11 def relations @relations end |
#stat ⇒ Object
Returns the value of attribute stat.
12 13 14 |
# File 'lib/webunit/params.rb', line 12 def stat @stat end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/webunit/params.rb', line 11 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
12 13 14 |
# File 'lib/webunit/params.rb', line 12 def value @value end |
Instance Method Details
#multipart_query_data(boundary) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/webunit/params.rb', line 31 def multipart_query_data( boundary) value = @value ? @value : '' if (@name) name = CGI::escape(@name) "--#{boundary}\n" + %!Content-Disposition: form-data; name="#{name}"\n! + "\n" + value + "\n" else nil end end |
#query_data ⇒ Object
26 27 28 29 |
# File 'lib/webunit/params.rb', line 26 def query_data value = @value ? CGI::escape( @value ) : '' @name ? ( CGI::escape( @name ) + '=' + value ) : nil end |
#update(p) ⇒ Object
22 23 24 |
# File 'lib/webunit/params.rb', line 22 def update( p ) @relations << p end |