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, #tel_uri, #to_spec, #unreserved, #uri_parameters, #user, #user_unreserved, #userinfo, #wsp

Constructor Details

#initializeToSpec

Returns a new instance of ToSpec.



254
255
256
257
258
259
260
# File 'lib/sip_parser.rb', line 254

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

Instance Attribute Details

#displaynameObject

Returns the value of attribute displayname.



253
254
255
# File 'lib/sip_parser.rb', line 253

def displayname
  @displayname
end

#is_nameaddrObject

Returns the value of attribute is_nameaddr.



253
254
255
# File 'lib/sip_parser.rb', line 253

def is_nameaddr
  @is_nameaddr
end

#paramsObject

Returns the value of attribute params.



253
254
255
# File 'lib/sip_parser.rb', line 253

def params
  @params
end

#uriObject

Returns the value of attribute uri.



253
254
255
# File 'lib/sip_parser.rb', line 253

def uri
  @uri
end

Instance Method Details

#addr_specObject



270
271
272
# File 'lib/sip_parser.rb', line 270

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

#display_nameObject



266
267
268
# File 'lib/sip_parser.rb', line 266

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

#parse(str) ⇒ Object



274
275
276
277
278
279
280
# File 'lib/sip_parser.rb', line 274

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

#to_paramObject



262
263
264
# File 'lib/sip_parser.rb', line 262

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

#to_sObject



282
283
284
285
286
287
288
289
# File 'lib/sip_parser.rb', line 282

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