Class: Web::Unit::Param

Inherits:
HtmlElem show all
Defined in:
lib/web/unit/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.



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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#relationsObject (readonly)

Returns the value of attribute relations.



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

def relations
  @relations
end

#statObject

Returns the value of attribute stat.



13
14
15
# File 'lib/web/unit/params.rb', line 13

def stat
  @stat
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#valueObject

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_dataObject



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