Class: SipcMessage::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rfetion/sipc_message.rb

Direct Known Subclasses

Bad, ExtentionRequired, NotFound, OK, Send, Unauthoried

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sections) ⇒ Response

Returns a new instance of Response.



141
142
143
# File 'lib/rfetion/sipc_message.rb', line 141

def initialize(sections)
  @sections = sections
end

Instance Attribute Details

#sectionsObject (readonly)

Returns the value of attribute sections.



139
140
141
# File 'lib/rfetion/sipc_message.rb', line 139

def sections
  @sections
end

Instance Method Details

#classObject



145
146
147
148
149
150
151
# File 'lib/rfetion/sipc_message.rb', line 145

def class
  if first_line =~ %r|^SIP-C/4.0 (\d{3})|
    RESPONSES[$1.to_i]
  else
    SipcMessage::OK
  end
end

#contain?(command) ⇒ Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/rfetion/sipc_message.rb', line 157

def contain?(command)
  @sections.find {|section| section.split("\r\n").first.index(%r|#{command} |) }
end

#first_lineObject



153
154
155
# File 'lib/rfetion/sipc_message.rb', line 153

def first_line
  @sections.first.split("\r\n").first
end

#to_sObject



161
162
163
# File 'lib/rfetion/sipc_message.rb', line 161

def to_s
  @sections.first.split("\r\n").first
end