Class: Asterisk::Action
- Inherits:
-
Object
- Object
- Asterisk::Action
- Includes:
- MessageHelper
- Defined in:
- lib/asterisk/action.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action_id ⇒ Object
-
#initialize(command, options = {}) ⇒ Action
constructor
A new instance of Action.
-
#send(connection) ⇒ Object
send the ami action.
-
#to_ami ⇒ Object
convert the action to ami string to send down wire.
- #to_hash ⇒ Object
Methods included from MessageHelper
#add_line, #ami_lines, #camelize, included
Constructor Details
#initialize(command, options = {}) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 |
# File 'lib/asterisk/action.rb', line 8 def initialize(command, ={}) @command = command @options = @options[:action_id] = Random.rand(99999999) unless @options[:action_id] end |
Class Method Details
Instance Method Details
#action_id ⇒ Object
24 25 26 |
# File 'lib/asterisk/action.rb', line 24 def action_id @options[:action_id] end |
#send(connection) ⇒ Object
send the ami action
20 21 22 |
# File 'lib/asterisk/action.rb', line 20 def send(connection) connection.write(self.to_ami) end |
#to_ami ⇒ Object
convert the action to ami string to send down wire
29 30 31 |
# File 'lib/asterisk/action.rb', line 29 def to_ami ami_lines(@command, @options) end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/asterisk/action.rb', line 33 def to_hash {:action => @command}.merge(@options) end |