Class: Punchblock::Component::Asterisk::AGI::Command

Inherits:
ComponentNode show all
Defined in:
lib/punchblock/component/asterisk/agi/command.rb

Defined Under Namespace

Classes: Complete, Param

Constant Summary

Constants inherited from RayoNode

RayoNode::InvalidNodeError

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComponentNode

#add_event, #complete_event, #complete_event=, #initialize, #register_event_handler, #register_internal_handlers, #response=, #stop!, #stop_action, #trigger_event_handler, #write_action

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=, #write_attr

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Constructor Details

This class inherits a constructor from Punchblock::Component::ComponentNode

Class Method Details

.new(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 10

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair { |k,v| new_node.send :"#{k}=", v }
  end
end

Instance Method Details

#inspect_attributesObject

:nodoc:



48
49
50
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 48

def inspect_attributes # :nodoc:
  [:name, :params_array] + super
end

#nameObject



16
17
18
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 16

def name
  read_attr :name
end

#name=(other) ⇒ Object



20
21
22
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 20

def name=(other)
  write_attr :name, other
end

#paramsArray[Param]

Returns params.

Returns:

  • (Array[Param])

    params



34
35
36
37
38
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 34

def params
  find('//ns:param', :ns => self.class.registered_ns).map do |i|
    Param.new i
  end
end

#params=(params) ⇒ Object

Parameters:

  • params (Hash, Array)

    A hash of key-value param pairs, or an array of Param objects



43
44
45
46
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 43

def params=(params)
  find('//ns:param', :ns => self.class.registered_ns).each(&:remove)
  [params].flatten.each { |i| self << Param.new(i) } if params.is_a? Array
end

#params_arrayArray[String]

Returns array of values of params.

Returns:

  • (Array[String])

    array of values of params



27
28
29
# File 'lib/punchblock/component/asterisk/agi/command.rb', line 27

def params_array
  params.map(&:value)
end