Class: RubyAMI::Event
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#receipt_time ⇒ Object
readonly
Returns the value of attribute receipt_time.
Attributes inherited from Response
Instance Method Summary collapse
-
#best_time ⇒ DateTime
The best known timestamp for the event.
-
#initialize(name, headers = {}) ⇒ Event
constructor
A new instance of Event.
- #inspect_attributes ⇒ Object
-
#timestamp ⇒ DateTime?
The timestamp of the event, or nil if none is available.
Methods inherited from Response
#[], #[]=, #action_id, #eql?, from_immediate_response, #has_text_body?, #headers, #inspect
Constructor Details
#initialize(name, headers = {}) ⇒ Event
Returns a new instance of Event.
8 9 10 11 12 |
# File 'lib/ruby_ami/event.rb', line 8 def initialize(name, headers = {}) @receipt_time = DateTime.now super headers @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ruby_ami/event.rb', line 6 def name @name end |
#receipt_time ⇒ Object (readonly)
Returns the value of attribute receipt_time.
6 7 8 |
# File 'lib/ruby_ami/event.rb', line 6 def receipt_time @receipt_time end |
Instance Method Details
#best_time ⇒ DateTime
Returns the best known timestamp for the event. Either its timestamp if specified, or its receipt time if not.
21 22 23 |
# File 'lib/ruby_ami/event.rb', line 21 def best_time || receipt_time end |
#inspect_attributes ⇒ Object
25 26 27 |
# File 'lib/ruby_ami/event.rb', line 25 def inspect_attributes [:name] + super end |
#timestamp ⇒ DateTime?
Returns the timestamp of the event, or nil if none is available.
15 16 17 18 |
# File 'lib/ruby_ami/event.rb', line 15 def return unless headers['Timestamp'] DateTime.strptime headers['Timestamp'], '%s' end |