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
Instance Attribute Summary
Attributes inherited from RayoNode
#call_id, #client, #component_id, #connection, #domain, #mixer_name, #original_component
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
10 11 12 13 14 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 10 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.
37 38 39 40 41 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 37 def attributes find('//ns:attribute', :ns => self.class.registered_ns).map do |i| Attribute.new i end end |
#attributes=(attributes) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 46 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.
27 28 29 30 31 32 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 27 def attributes_hash attributes.inject({}) do |hash, attribute| hash[attribute.name] = attribute.value hash end end |
#inspect_attributes ⇒ Object
:nodoc:
55 56 57 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 55 def inspect_attributes # :nodoc: [:name, :attributes_hash] + super end |
#name ⇒ Object
16 17 18 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 16 def name read_attr :name end |
#name=(other) ⇒ Object
20 21 22 |
# File 'lib/punchblock/event/asterisk/ami/event.rb', line 20 def name=(other) write_attr :name, other end |