Class: Watobo::HTTP::Url
- Inherits:
-
Object
- Object
- Watobo::HTTP::Url
- Defined in:
- lib/watobo/http/url/url.rb
Instance Method Summary collapse
- #has_parm?(parm_name) ⇒ Boolean
-
#initialize(root) ⇒ Url
constructor
A new instance of Url.
- #parameters(&block) ⇒ Object
- #set(parm) ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Method Details
#has_parm?(parm_name) ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/watobo/http/url/url.rb', line 18 def has_parm?(parm_name) @root.get_parm_names do |pn| return true if pn == parm_name end false end |
#parameters(&block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/watobo/http/url/url.rb', line 25 def parameters(&block) parms = [] @root.get_parms.each do |p| p.strip! i = p.index("=") name = p[0..i-1] val = i < p.length ? p[i+1..-1] : "" parms << Watobo::UrlParameter.new( :name => name, :value => val ) end parms end |
#set(parm) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/watobo/http/url/url.rb', line 10 def set(parm) if has_parm?(parm.name) @root.replace_get_parm(parm.name, parm.value) else @root.add_get_parm(parm.name, parm.value) end end |
#to_s ⇒ Object
5 6 7 |
# File 'lib/watobo/http/url/url.rb', line 5 def to_s s = @root.url_string end |