Sha256: 75154afee19ab3c49ce1291b34ef80805987298cffd732f46f198ffaa526609d
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true require_relative "../base" require_relative "../events/event" module Fusuma module Plugin module Detectors # Inherite this base class Detector < Base # @return [Array<String>] def sources @source ||= self.class.const_get(:SOURCES) end # Always watch buffers and detect them or not # @return [TrueClass,FalseClass] def watch? false end # @param _buffers [Array<Buffer>] # @return [Event] if event is detected # @return [NilClass] if event is NOT detected def detect(_buffers) raise NotImplementedError, "override #{self.class.name}##{__method__}" # create_event(record:) end # @param record [Events::Records::Record] # @return [Events::Event] def create_event(record:) @last_time = Time.now Events::Event.new(time: @last_time, tag: tag, record: record) end def last_time @last_time ||= Time.now end def first_time? @last_time.nil? end def tag self.class.tag end def type self.class.type end class << self def tag name.split("Detectors::").last.underscore end def type(tag_name = tag) tag_name.gsub("_detector", "") end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fusuma-2.5.1 | lib/fusuma/plugin/detectors/detector.rb |
fusuma-2.5.0 | lib/fusuma/plugin/detectors/detector.rb |