Class: Watobo::HTTP::Url

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

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Url

Returns a new instance of Url.



37
38
39
40
# File 'lib/watobo/http/url/url.rb', line 37

def initialize(root)
   @root = root

end

Instance Method Details

#has_parm?(parm_name) ⇒ Boolean

Returns:

  • (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_sObject



5
6
7
# File 'lib/watobo/http/url/url.rb', line 5

def to_s
  s = @root.url_string
end