Class: Web::Unit::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.
15 16 17 18 19 20 21 |
# File 'lib/web/unit/params.rb', line 15 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.
12 13 14 |
# File 'lib/web/unit/params.rb', line 12 def name @name end |
#relations ⇒ Object (readonly)
Returns the value of attribute relations.
12 13 14 |
# File 'lib/web/unit/params.rb', line 12 def relations @relations end |
#stat ⇒ Object
Returns the value of attribute stat.
13 14 15 |
# File 'lib/web/unit/params.rb', line 13 def stat @stat end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/web/unit/params.rb', line 12 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
13 14 15 |
# File 'lib/web/unit/params.rb', line 13 def value @value end |
Instance Method Details
#multipart_query_data(boundary) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/web/unit/params.rb', line 32 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
27 28 29 30 |
# File 'lib/web/unit/params.rb', line 27 def query_data value = @value ? CGI::escape( @value ) : '' @name ? ( CGI::escape( @name ) + '=' + value ) : nil end |
#update(p) ⇒ Object
23 24 25 |
# File 'lib/web/unit/params.rb', line 23 def update( p ) @relations << p end |