class RubyAsterisk::Response
Class for response coming from Asterisk
Attributes
action_id[RW]
data[RW]
message[RW]
raw_response[RW]
type[RW]
Public Class Methods
new(type,response)
click to toggle source
# File lib/ruby-asterisk/response.rb, line 11 def initialize(type,response) self.raw_response = response self.type = type self.action_id = self._parse_action_id self.message = self._parse_message self.data = self._parse_response end
Public Instance Methods
success()
click to toggle source
# File lib/ruby-asterisk/response.rb, line 19 def success self.raw_response.include?("Response: Success") end
Protected Instance Methods
_parse(field)
click to toggle source
# File lib/ruby-asterisk/response.rb, line 33 def _parse(field) _value = nil self.raw_response.each_line do |line| if line.start_with?(field) _value = line[line.rindex(":")+1..line.size].strip end end _value end
_parse_action_id()
click to toggle source
# File lib/ruby-asterisk/response.rb, line 25 def _parse_action_id self._parse("ActionID:") end
_parse_message()
click to toggle source
# File lib/ruby-asterisk/response.rb, line 29 def _parse_message self._parse("Message:") end
_parse_response()
click to toggle source
# File lib/ruby-asterisk/response.rb, line 43 def _parse_response ResponseParser.parse(self.raw_response, self.type) end