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) ⇒ TimedEvent
constructor
Builds a new TimedEvent.
- #to_json(*a) ⇒ Object
Methods included from Monitored
Constructor Details
#initialize(name, duration = nil) ⇒ TimedEvent
Builds a new Hallmonitor::TimedEvent
14 15 16 17 |
# File 'lib/hallmonitor/timed_event.rb', line 14 def initialize(name, duration=nil) super(name) @duration = duration end |
Instance Attribute Details
#duration ⇒ Number
Reports duration of this timed event in ms
28 29 30 31 32 33 34 |
# File 'lib/hallmonitor/timed_event.rb', line 28 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
36 37 38 39 40 41 42 43 44 |
# File 'lib/hallmonitor/timed_event.rb', line 36 def to_json(*a) { name: @name, time: @time, start: @start, stop: @stop, duration: self.duration }.to_json(*a) end |