Class: Punchblock::Translator::Asterisk::AGICommand

Inherits:
Object
  • Object
show all
Defined in:
lib/punchblock/translator/asterisk/agi_command.rb

Constant Summary

ARG_QUOTER =
/["\\]/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, channel, command, *params) ⇒ AGICommand

Returns a new instance of AGICommand



14
15
16
# File 'lib/punchblock/translator/asterisk/agi_command.rb', line 14

def initialize(id, channel, command, *params)
  @id, @channel, @command, @params = id, channel, command, params
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id



12
13
14
# File 'lib/punchblock/translator/asterisk/agi_command.rb', line 12

def id
  @id
end

Instance Method Details

#execute(ami_client) ⇒ Object



19
20
21
# File 'lib/punchblock/translator/asterisk/agi_command.rb', line 19

def execute(ami_client)
  AMIErrorConverter.convert { ami_client.send_action 'AGI', 'Channel' => @channel, 'Command' => agi_command, 'CommandID' => id }
end

#parse_result(event) ⇒ Object



23
24
25
26
# File 'lib/punchblock/translator/asterisk/agi_command.rb', line 23

def parse_result(event)
  parser = RubyAMI::AGIResultParser.new event['Result']
  {code: parser.code, result: parser.result, data: parser.data}
end