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.



55
56
57
58
# File 'lib/watobo/http/url/url.rb', line 55

def initialize(root)
   @root = root

end

Instance Method Details

#has_parm?(parm_name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
# File 'lib/watobo/http/url/url.rb', line 39

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

#parameters(&block) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/watobo/http/url/url.rb', line 46

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

#set(parm) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/watobo/http/url/url.rb', line 31

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



26
27
28
# File 'lib/watobo/http/url/url.rb', line 26

def to_s
  s = @root.url_string
end