Class: Qpid::Proton::URL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = nil, options = {}) ⇒ URL

Returns a new instance of URL.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/core/url.rb', line 31

def initialize(url = nil, options = {})
  options[:defaults] = true

  if url
    @url = Cproton.pn_url_parse(url)
    if @url.nil?
      raise ::ArgumentError.new("invalid url: #{url}")
    end
  else
    @url = Cproton.pn_url
  end
  @scheme = Cproton.pn_url_get_scheme(@url)
  @username = Cproton.pn_url_get_username(@url)
  @password = Cproton.pn_url_get_password(@url)
  @host = Cproton.pn_url_get_host(@url)
  @port = Cproton.pn_url_get_port(@url)
  @path = Cproton.pn_url_get_path(@url)
  defaults
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



27
28
29
# File 'lib/core/url.rb', line 27

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#pathObject (readonly)

Returns the value of attribute path.



29
30
31
# File 'lib/core/url.rb', line 29

def path
  @path
end

#portObject

Returns the value of attribute port.



28
29
30
# File 'lib/core/url.rb', line 28

def port
  @port
end

#schemeObject (readonly)

Returns the value of attribute scheme.



24
25
26
# File 'lib/core/url.rb', line 24

def scheme
  @scheme
end

#usernameObject (readonly)

Returns the value of attribute username.



25
26
27
# File 'lib/core/url.rb', line 25

def username
  @username
end

Instance Method Details

#to_sObject



63
64
65
# File 'lib/core/url.rb', line 63

def to_s
  "#{@scheme}://#{@username.nil? ? '' : @username}#{@password.nil? ? '' : '@' + @password + ':'}#{@host}:#{@port}/#{@path}"
end