Class: Hallmonitor::TimedEvent
- Defined in:
- lib/hallmonitor/timed_event.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
Reports duration of this timed event in ms.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(name, duration = nil) ⇒ TimedEvent
constructor
A new instance of TimedEvent.
- #to_json(*a) ⇒ Object
Methods included from Monitored
Constructor Details
#initialize(name, duration = nil) ⇒ TimedEvent
Returns a new instance of TimedEvent.
5 6 7 8 |
# File 'lib/hallmonitor/timed_event.rb', line 5 def initialize(name, duration=nil) super(name) @duration = duration end |
Instance Attribute Details
#duration ⇒ Object
Reports duration of this timed event in ms
15 16 17 18 19 20 21 |
# File 'lib/hallmonitor/timed_event.rb', line 15 def duration if @duration @duration elsif @start && @stop (@stop - @start) * 1000 end end |
#start ⇒ Object
Returns the value of attribute start.
3 4 5 |
# File 'lib/hallmonitor/timed_event.rb', line 3 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
3 4 5 |
# File 'lib/hallmonitor/timed_event.rb', line 3 def stop @stop end |
Instance Method Details
#to_json(*a) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/hallmonitor/timed_event.rb', line 23 def to_json(*a) { name: @name, time: @time, start: @start, stop: @stop, duration: self.duration }.to_json(*a) end |