Class: Punchblock::Event::Asterisk::AMI::Event
- Inherits:
-
Punchblock::Event
- Object
- Niceogiri::XML::Node
- RayoNode
- Punchblock::Event
- Punchblock::Event::Asterisk::AMI::Event
- Defined in:
- lib/punchblock/event/asterisk/ami/event.rb
Defined Under Namespace
Classes: Attribute
Constant Summary
Constants inherited from RayoNode
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
-
#attributes ⇒ Array[Attribute]
Attributes.
- #attributes=(attributes) ⇒ Object
-
#attributes_hash ⇒ Hash
Hash of key-value pairs of attributes.
-
#inspect_attributes ⇒ Object
:nodoc:.
- #name ⇒ Object
- #name=(other) ⇒ Object
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, register, #source
Class Method Details
.new(options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 12 def self.new( = {}) super().tap do |new_node| .each_pair { |k,v| new_node.send :"#{k}=", v } end end |
Instance Method Details
#attributes ⇒ Array[Attribute]
Returns attributes.
39 40 41 42 43 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 39 def attributes find('//ns:attribute', :ns => self.class.registered_ns).map do |i| Attribute.new i end end |
#attributes=(attributes) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 48 def attributes=(attributes) find('//ns:attribute', :ns => self.class.registered_ns).each(&:remove) if attributes.is_a? Hash attributes.each_pair { |k,v| self << Attribute.new(k, v) } elsif attributes.is_a? Array [attributes].flatten.each { |i| self << Attribute.new(i) } end end |
#attributes_hash ⇒ Hash
Returns hash of key-value pairs of attributes.
29 30 31 32 33 34 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 29 def attributes_hash attributes.inject({}) do |hash, attribute| hash[attribute.name.downcase.gsub('-', '_').to_sym] = attribute.value hash end end |
#inspect_attributes ⇒ Object
:nodoc:
57 58 59 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 57 def inspect_attributes # :nodoc: [:name, :attributes_hash] + super end |
#name ⇒ Object
18 19 20 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 18 def name read_attr :name end |
#name=(other) ⇒ Object
22 23 24 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 22 def name=(other) write_attr :name, other end |