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, #merge_headers!
Constructor Details
#initialize(name, headers = {}) ⇒ Event
Returns a new instance of Event.
10 11 12 13 14 |
# File 'lib/ruby_ami/event.rb', line 10 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.
8 9 10 |
# File 'lib/ruby_ami/event.rb', line 8 def name @name end |
#receipt_time ⇒ Object (readonly)
Returns the value of attribute receipt_time.
8 9 10 |
# File 'lib/ruby_ami/event.rb', line 8 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.
23 24 25 |
# File 'lib/ruby_ami/event.rb', line 23 def best_time || receipt_time end |
#inspect_attributes ⇒ Object
27 28 29 |
# File 'lib/ruby_ami/event.rb', line 27 def inspect_attributes [:name] + super end |
#timestamp ⇒ DateTime?
Returns the timestamp of the event, or nil if none is available.
17 18 19 20 |
# File 'lib/ruby_ami/event.rb', line 17 def return unless headers['Timestamp'] DateTime.strptime headers['Timestamp'], '%s' end |