Class: Watobo::HTTPData::WWW_Form

Inherits:
Base
  • Object
show all
Defined in:
lib/watobo/http/data/data.rb

Instance Method Summary collapse

Methods inherited from Base

#to_s

Constructor Details

#initialize(root) ⇒ WWW_Form

Returns a new instance of WWW_Form.


60
61
62
63
# File 'lib/watobo/http/data/data.rb', line 60

def initialize(root)
  super root

end

Instance Method Details

#has_parm?(parm_name) ⇒ Boolean

Returns:

  • (Boolean)

44
45
46
47
48
49
# File 'lib/watobo/http/data/data.rb', line 44

def has_parm?(parm_name)
  @root.post_parm_names do |pn|
    return true if pn == parm_name
  end
  false
end

#parameters(&block) ⇒ Object


51
52
53
54
55
56
57
58
# File 'lib/watobo/http/data/data.rb', line 51

def parameters(&block)
  parms = []
  @root.post_parms.each do |p|
    name, val = p.split("=")
    parms << Watobo::WWWFormParameter.new( :name => name, :value => val )
  end
  parms
end

#set(parm) ⇒ Object


36
37
38
39
40
41
42
# File 'lib/watobo/http/data/data.rb', line 36

def set(parm)
  if has_parm?(parm.name)
  @root.replace_post_parm(parm.name, parm.value)
  else
  @root.add_post_parm(parm.name, parm.value)
  end
end