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

Instance Method Summary collapse

Methods inherited from Uri

#aor, #del_param, #get_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.



7
8
9
10
11
12
13
14
15
16
# File 'lib/oversip/sip/name_addr.rb', line 7

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
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

Instance Method Details

#modified?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/oversip/sip/name_addr.rb', line 36

def modified?
  @uri_modified or @name_addr_modified
end

#to_sObject Also known as: inspect



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/oversip/sip/name_addr.rb', line 23

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