Class: WebUnit::Param

Inherits:
HtmlElem show all
Defined in:
lib/webunit/params.rb

Direct Known Subclasses

Input, Select, Textarea

Instance Attribute Summary collapse

Attributes inherited from HtmlElem

#array, #attrs, #children, #data, #tag

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/webunit/params.rb', line 11

def name
  @name
end

#relationsObject (readonly)

Returns the value of attribute relations.



11
12
13
# File 'lib/webunit/params.rb', line 11

def relations
  @relations
end

#statObject

Returns the value of attribute stat.



12
13
14
# File 'lib/webunit/params.rb', line 12

def stat
  @stat
end

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/webunit/params.rb', line 11

def type
  @type
end

#valueObject

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_dataObject



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