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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Methods included from CustomProcess

#fork

Class Method Details

.tagObject



55
56
57
# File 'lib/fusuma/plugin/detectors/detector.rb', line 55

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

.type(tag_name = tag) ⇒ Object



59
60
61
# File 'lib/fusuma/plugin/detectors/detector.rb', line 59

def type(tag_name = tag)
  tag_name.gsub('_detector', '')
end

Instance Method Details

#create_event(record:) ⇒ Events::Event

Parameters:

Returns:



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

def create_event(record:)
  @last_time = Time.now
  Events::Event.new(time: @last_time, 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)


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

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

  # create_event(record:)
end

#first_time?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fusuma/plugin/detectors/detector.rb', line 42

def first_time?
  @last_time.nil?
end

#last_timeObject



38
39
40
# File 'lib/fusuma/plugin/detectors/detector.rb', line 38

def last_time
  @last_time ||= Time.now
end

#sourcesArray<String>

Returns:



12
13
14
# File 'lib/fusuma/plugin/detectors/detector.rb', line 12

def sources
  @source ||= self.class.const_get('SOURCES')
end

#tagObject



46
47
48
# File 'lib/fusuma/plugin/detectors/detector.rb', line 46

def tag
  self.class.tag
end

#typeObject



50
51
52
# File 'lib/fusuma/plugin/detectors/detector.rb', line 50

def type
  self.class.type
end

#watch?TrueClass, FalseClass

Always watch buffers and detect them or not

Returns:

  • (TrueClass, FalseClass)


18
19
20
# File 'lib/fusuma/plugin/detectors/detector.rb', line 18

def watch?
  false
end