Class: Quaff::ToSpec
- Inherits:
-
ABNFSipParser
- Object
- ABNFSipParser
- Quaff::ToSpec
- Defined in:
- lib/sip_parser.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#displayname ⇒ Object
Returns the value of attribute displayname.
-
#is_nameaddr ⇒ Object
Returns the value of attribute is_nameaddr.
-
#params ⇒ Object
Returns the value of attribute params.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #addr_spec ⇒ Object
- #display_name ⇒ Object
-
#initialize ⇒ ToSpec
constructor
A new instance of ToSpec.
- #parse(str) ⇒ Object
- #to_param ⇒ Object
- #to_s ⇒ Object
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
#initialize ⇒ ToSpec
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
#displayname ⇒ Object
Returns the value of attribute displayname.
231 232 233 |
# File 'lib/sip_parser.rb', line 231 def displayname @displayname end |
#is_nameaddr ⇒ Object
Returns the value of attribute is_nameaddr.
231 232 233 |
# File 'lib/sip_parser.rb', line 231 def is_nameaddr @is_nameaddr end |
#params ⇒ Object
Returns the value of attribute params.
231 232 233 |
# File 'lib/sip_parser.rb', line 231 def params @params end |
#uri ⇒ Object
Returns the value of attribute uri.
231 232 233 |
# File 'lib/sip_parser.rb', line 231 def uri @uri end |
Instance Method Details
#addr_spec ⇒ Object
248 249 250 |
# File 'lib/sip_parser.rb', line 248 def addr_spec super.set_block {|p| @uri = p} end |
#display_name ⇒ Object
244 245 246 |
# File 'lib/sip_parser.rb', line 244 def display_name super.set_block {|p| @display_name = p; @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_param ⇒ Object
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_s ⇒ Object
260 261 262 263 264 265 266 267 |
# File 'lib/sip_parser.rb', line 260 def to_s paramstr = @params.collect {|k, v| if (v == true) then ";#{k}" else ";#{k}=#{v}" end}.join("") if @is_nameaddr "#{@displayname} <#{@uri}>#{paramstr}" else "#{@uri}#{paramstr}" end end |