Class: Qpid::Proton::URL Deprecated

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

Overview

Deprecated.

use URI or String

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = nil) ⇒ URL

Parse a string, return a new URL

Parameters:

  • url (#to_s) (defaults to: nil)

    the URL string



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

def initialize(url = nil)
  deprecated self.class, 'URI or String'
  if url
    @url = Cproton.pn_url_parse(url.to_s)
    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

#host (readonly)



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

def host
  @host
end

#password (readonly)



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

def password
  @password
end

#path (readonly)



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

def path
  @path
end

#scheme (readonly)



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

def scheme
  @scheme
end

#username (readonly) Also known as: user



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

def username
  @username
end

Instance Method Details

#port



61
62
63
# File 'lib/core/url.rb', line 61

def port
  Cproton.pn_url_get_port(@url).to_i
end

#port=(port)



53
54
55
56
57
58
59
# File 'lib/core/url.rb', line 53

def port=(port)
  if port.nil?
    Cproton.pn_url_set_port(@url, nil)
  else
    Cproton.pn_url_set_port(@url, port)
  end
end

#to_sString Also known as: to_str

Returns Convert to string.

Returns:

  • (String)

    Convert to string



66
67
68
# File 'lib/core/url.rb', line 66

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