Sha256: ddc5bd5e1d66b6d2139fca3c2cd459adf74ebc9ca152e7c9e7f5786fd372e608
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 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 def initialize(*args) super @tag = self.class.tag @type = self.class.type end attr_reader :tag attr_reader :type # @return [Array<String>] def sources @sources ||= 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fusuma-3.7.0 | lib/fusuma/plugin/detectors/detector.rb |
fusuma-3.6.2 | lib/fusuma/plugin/detectors/detector.rb |
fusuma-3.6.1 | lib/fusuma/plugin/detectors/detector.rb |