Class: Hallmonitor::TimedEvent
- Defined in:
- lib/hallmonitor/timed_event.rb
Overview
An event that represents a span of time
Instance Attribute Summary collapse
-
#duration ⇒ Number
Reports duration of this timed event in ms.
-
#start ⇒ DateTime
The start time of this timed event.
-
#stop ⇒ DateTime
The stop time of this timed event.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(name, duration: nil, tags: {}) ⇒ TimedEvent
constructor
Builds a new TimedEvent.
- #to_json(*a) ⇒ Object
Methods included from Monitored
Constructor Details
#initialize(name, duration: nil, tags: {}) ⇒ TimedEvent
Builds a new Hallmonitor::TimedEvent
15 16 17 18 |
# File 'lib/hallmonitor/timed_event.rb', line 15 def initialize(name, duration: nil, tags: {}) super(name, tags: ) @duration = duration end |
Instance Attribute Details
#duration ⇒ Number
Reports duration of this timed event in ms
29 30 31 32 33 34 35 |
# File 'lib/hallmonitor/timed_event.rb', line 29 def duration if @duration @duration elsif @start && @stop (@stop - @start) * 1000 end end |
#start ⇒ DateTime
Returns the start time of this timed event.
9 10 11 |
# File 'lib/hallmonitor/timed_event.rb', line 9 def start @start end |
#stop ⇒ DateTime
Returns the stop time of this timed event.
9 |
# File 'lib/hallmonitor/timed_event.rb', line 9 attr_accessor :start, :stop |
Instance Method Details
#to_json(*a) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hallmonitor/timed_event.rb', line 37 def to_json(*a) { name: name, time: time, start: @start, stop: @stop, duration: duration, tags: }.to_json(*a) end |