Class: OverSIP::SIP::NameAddr

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

Instance Attribute Summary collapse

Attributes inherited from Uri

#headers, #host, #host_type, #ovid_param, #params, #phone_context_param, #port, #scheme, #transport_param, #user

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Uri

#aor, #clear_params, #del_param, #get_param, #has_param?, #lr_param?, #ob_param?, #set_param, #sip?, #tel?, #unknown_scheme?, #uri

Constructor Details

#initialize(display_name = nil, scheme = :sip, user = nil, host = nil, port = nil) ⇒ NameAddr

Returns a new instance of NameAddr.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/oversip/sip/name_addr.rb', line 15

def initialize display_name=nil, scheme=:sip, user=nil, host=nil, port=nil
  @display_name = display_name
  @scheme = scheme.to_sym
  @user = user
  @host = host
  @host_type = ::OverSIP::Utils.ip_type(host) || :domain  if host
  @port = port

  @name_addr_modified = true
  @uri_modified = true
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



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

def display_name
  @display_name
end

Class Method Details

.parse(value) ⇒ Object



8
9
10
11
12
# File 'lib/oversip/sip/name_addr.rb', line 8

def self.parse value
  name_addr = ::OverSIP::SIP::MessageParser.parse_uri value, true
  raise ::OverSIP::ParsingError, "invalid NameAddr #{value.inspect}"  unless name_addr.is_a? (::OverSIP::SIP::NameAddr)
  name_addr
end

Instance Method Details

#modified?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/oversip/sip/name_addr.rb', line 45

def modified?
  @uri_modified or @name_addr_modified
end

#to_sObject Also known as: inspect



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/oversip/sip/name_addr.rb', line 32

def to_s
  return @name_addr  if @name_addr and not @name_addr_modified and not @uri_modified

  @name_addr = ""
  ( @name_addr << '"' << @display_name << '" ' )  if @display_name
  @name_addr << "<" << uri << ">"

  @name_addr_modified = false
  @name_addr

end