Class: OverSIP::SIP::Uri

Inherits:
Object
  • Object
show all
Defined in:
lib/oversip/sip/grammar/uri.rb,
ext/sip_parser/sip_parser_ruby.c

Direct Known Subclasses

NameAddr

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def headers
  @headers
end

#hostObject Also known as: domain

Returns the value of attribute host.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def host
  @host
end

#host_typeObject

Returns the value of attribute host_type.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def host_type
  @host_type
end

#ovid_paramObject (readonly)

Returns the value of attribute ovid_param.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def ovid_param
  @ovid_param
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def params
  @params
end

#phone_context_paramObject (readonly)

Returns the value of attribute phone_context_param.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def phone_context_param
  @phone_context_param
end

#portObject

Returns the value of attribute port.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def port
  @port
end

#schemeObject

Returns the value of attribute scheme.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def scheme
  @scheme
end

#transport_paramObject (readonly)

Returns the value of attribute transport_param.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def transport_param
  @transport_param
end

#uri_modifiedObject

Returns the value of attribute uri_modified.



5
6
7
# File 'lib/oversip/sip/grammar/uri.rb', line 5

def uri_modified
  @uri_modified
end

#userObject Also known as: number

Returns the value of attribute user.



4
5
6
# File 'lib/oversip/sip/grammar/uri.rb', line 4

def user
  @user
end

Instance Method Details

#del_param(k) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/oversip/sip/grammar/uri.rb', line 56

def del_param k
  return nil  if unknown_scheme?
  return false  unless @params
  if @params.include?(k=k.downcase)
    @uri_modified = true
    return @params.delete(k)
  end
  false
end

#lr_param?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/oversip/sip/grammar/uri.rb', line 66

def lr_param?
  @lr_param ? true : false
end

#ob_param?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/oversip/sip/grammar/uri.rb', line 70

def ob_param?
  @ob_param ? true : false
end

#set_param(k, v) ⇒ Object



49
50
51
52
53
54
# File 'lib/oversip/sip/grammar/uri.rb', line 49

def set_param k, v
  return nil  if unknown_scheme?
  @params ||= {}
  @params[k.downcase] = v
  @uri_modified = true
end

#unknown_scheme?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/oversip/sip/grammar/uri.rb', line 13

def unknown_scheme?
  not @scheme.is_a? Symbol
end

#uriObject Also known as: to_s, inspect



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/oversip/sip/grammar/uri.rb', line 80

def uri
  return @uri  unless @uri_modified

  case @scheme
    when :sip, :sips
      @uri = @scheme.to_s << ":"
      ( @uri << ::EscapeUtils.escape_uri(@user) << "@" )  if @user
      @uri << @host
      ( @uri << ":" << @port.to_s )  if @port

      @params.each do |k,v|
        @uri << ";" << k
        ( @uri << "=" << v.to_s )  if v
      end  if @params

      @uri << @headers  if @headers

    when :tel
      @uri = "tel:"
      @uri << @user

      @params.each do |k,v|
        @uri << ";" << k
        ( @uri << "=" << v.to_s )  if v
      end  if @params

    end

  @uri_modified = false
  @uri
end