class Fusuma::Plugin::Buffers::TimerBuffer
manage events and generate command
Constants
- DEFAULT_SECONDS_TO_KEEP
- DEFAULT_SOURCE
Public Instance Methods
buffer(event)
click to toggle source
@param event [Event] @return [Buffer, NilClass]
# File lib/fusuma/plugin/buffers/timer_buffer.rb, line 22 def buffer(event) return if event&.tag != source @events.push(event) self end
clear_expired(current_time: Time.now)
click to toggle source
# File lib/fusuma/plugin/buffers/timer_buffer.rb, line 29 def clear_expired(current_time: Time.now) @seconds_to_keep ||= (config_params(:seconds_to_keep) || DEFAULT_SECONDS_TO_KEEP) @events.each do |e| break if current_time - e.time < @seconds_to_keep @events.delete(e) end end
config_param_types()
click to toggle source
# File lib/fusuma/plugin/buffers/timer_buffer.rb, line 13 def config_param_types { source: [String], seconds_to_keep: [Float, Integer] } end
empty?()
click to toggle source
# File lib/fusuma/plugin/buffers/timer_buffer.rb, line 38 def empty? @events.empty? end