class Hallmonitor::TimedEvent
An event that represents a span of time
Attributes
duration[W]
@!attribute [w] duration
Duration, should be set in ms, will take precedence over calculating via start and stop times @return [Number] the currently value of duration
start[RW]
@!attribute start
@return [DateTime] the start time of this timed event
@!attribute stop
@return [DateTime] the stop time of this timed event
stop[RW]
@!attribute start
@return [DateTime] the start time of this timed event
@!attribute stop
@return [DateTime] the stop time of this timed event
Public Class Methods
new(name, duration: nil, tags: {})
click to toggle source
Builds a new {TimedEvent} @param name [String] name of this event @param duration [Number, Hash] the timespan of this event, or multiple named
timestamps
Calls superclass method
Hallmonitor::Event::new
# File lib/hallmonitor/timed_event.rb, line 15 def initialize(name, duration: nil, tags: {}) super(name, tags: tags) @duration = duration end
Public Instance Methods
duration()
click to toggle source
Reports duration of this timed event in ms @return [Number] duration, in ms if calculated based on
{#start} and {#stop}
# File lib/hallmonitor/timed_event.rb, line 29 def duration if @duration @duration elsif @start && @stop (@stop - @start) * 1000 end end
to_json(*a)
click to toggle source
# File lib/hallmonitor/timed_event.rb, line 37 def to_json(*a) { name: name, time: time, start: @start, stop: @stop, duration: duration, tags: tags }.to_json(*a) end