Class: Quaff::ToSpec

Inherits:
ABNFSipParser show all
Defined in:
lib/sip_parser.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ABNFSipParser

#alphanum, #escaped, #from_param, #from_spec, #hostname, #hostport, #laquot, #lws, #mark, #name_addr, #param, #paramchar, #pname, #port, #pvalue, #raquot, #reserved, #sip_uri, #sws, #to_spec, #unreserved, #uri_parameters, #user, #user_unreserved, #userinfo, #wsp

Constructor Details

#initializeToSpec

Returns a new instance of ToSpec.



232
233
234
235
236
237
238
# File 'lib/sip_parser.rb', line 232

def initialize
  super
  @params = {}
  @uri = nil
  @displayname = nil
  @is_nameaddr = false
end

Instance Attribute Details

#displaynameObject

Returns the value of attribute displayname.



231
232
233
# File 'lib/sip_parser.rb', line 231

def displayname
  @displayname
end

#is_nameaddrObject

Returns the value of attribute is_nameaddr.



231
232
233
# File 'lib/sip_parser.rb', line 231

def is_nameaddr
  @is_nameaddr
end

#paramsObject

Returns the value of attribute params.



231
232
233
# File 'lib/sip_parser.rb', line 231

def params
  @params
end

#uriObject

Returns the value of attribute uri.



231
232
233
# File 'lib/sip_parser.rb', line 231

def uri
  @uri
end

Instance Method Details

#addr_specObject



248
249
250
# File 'lib/sip_parser.rb', line 248

def addr_spec
  super.set_block {|p| @uri = p}
end

#display_nameObject



244
245
246
# File 'lib/sip_parser.rb', line 244

def display_name
  super.set_block {|p| @displayname = p.strip; @is_nameaddr = true}
end

#parse(str) ⇒ Object



252
253
254
255
256
257
258
# File 'lib/sip_parser.rb', line 252

def parse(str)
  if to_spec.match(Stream.new(str))
    true
  else
    false
  end
end

#to_paramObject



240
241
242
# File 'lib/sip_parser.rb', line 240

def to_param
  super.set_block {|p| k, v = p.split("="); @params[k] = if v.nil? then true else v end}
end

#to_sObject



260
261
262
263
264
265
266
267
# File 'lib/sip_parser.rb', line 260

def to_s
  paramstr = Utils.paramhash_to_str(@params)
  if @is_nameaddr
    "#{@displayname} <#{@uri}>#{paramstr}"
  else
    "#{@uri}#{paramstr}"
  end
end