Class: Fusuma::Plugin::Detectors::Detector

Inherits:
Base
  • Object
show all
Defined in:
lib/fusuma/plugin/detectors/detector.rb

Overview

Inherite this base

Direct Known Subclasses

PinchDetector, RotateDetector, SwipeDetector

Instance Method Summary collapse

Methods inherited from Base

#config_index, #config_param_types, #config_params, inherited, plugins

Instance Method Details

#create_event(record:) ⇒ Events::Event

Parameters:

Returns:



22
23
24
25
# File 'lib/fusuma/plugin/detectors/detector.rb', line 22

def create_event(record:)
  @last_time = Time.now
  Events::Event.new(time: Time.now, tag: tag, record: record)
end

#detect(_buffers) ⇒ Event, NilClass

Parameters:

  • _buffers (Array<Buffer>)

Returns:

  • (Event)

    if event is detected

  • (NilClass)

    if event is NOT detected

Raises:

  • (NotImplementedError)


14
15
16
17
18
# File 'lib/fusuma/plugin/detectors/detector.rb', line 14

def detect(_buffers)
  raise NotImplementedError, "override #{self.class.name}##{__method__}"

  # create_event(record:)
end

#last_timeObject



27
28
29
# File 'lib/fusuma/plugin/detectors/detector.rb', line 27

def last_time
  @last_time ||= Time.now
end

#tagObject



31
32
33
# File 'lib/fusuma/plugin/detectors/detector.rb', line 31

def tag
  self.class.name.split('Detectors::').last.underscore
end

#typeObject



35
36
37
# File 'lib/fusuma/plugin/detectors/detector.rb', line 35

def type
  self.class.name.underscore.split('/').last.gsub('_detector', '')
end