Class OverSIP::SIP::NameAddr

An instance of the OverSIP::SIP::NameAddr class contains a “name-addr” or a “addr-spec” value as stated in the BNF grammar of the RFC 3261.

  • A “name-addr” value is in the form “display name <URI>”. Example:
    From: "Alice" <sip:alice@atlanta.com>
    
  • A “addr-spec” value is an URI. Example:
    From: sip:alice@atlanta.com
    

Parent class

OverSIP::SIP::NameAddr inherits all the methods of OverSIP::SIP::Uri and thus all the parent methods are available for retrieving data from the URI.

Class methods

parse(name_addr)

NEW in 1.4.x

Parses the given name_addr into a OverSIP::SIP::NameAddr instance and returns it.

Parameters

name_addr
String containing the NameAddr to parse.

Examples

name_addr = OverSIP::SIP::NameAddr.parse '"Iñaki" <sip:ibc@aliax.net>'
name_addr = OverSIP::SIP::Uri.parse "<tel:+123456789>"
name_addr = OverSIP::SIP::Uri.parse "sip:ibc@aliax.net"

Class instance methods

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

Initializer method for the OverSIP::SIP::NameAddr instance. It should be just used for SIP, SIPS or TEL URI’s.

Parameters

display_name
The display name value (String or nil if not present).
scheme
URI scheme (:sip, :sips or :tel Symbol).
user
SIP URI username or TEL URI number (String).
host
SIP URI host value.
port
SIP URI port value.

Examples

name_addr = OverSIP::SIP::NameAddr.new "Alice", :sip, "alice", "example.net"
name_addr = OverSIP::SIP::NameAddr.new "Bob", :tel, "+12345678"

display_name

Gets the display name value (String or nil if not present).

Example

request.from.display_name
#=> "Alice"

display_name=(value)

Sets the display name.

value
The new display name (String or nil for removing it).

Example

request.from.display_name = "Bob"
#=> "Bob"