Class: Fusuma::Plugin::Detectors::Detector
- Defined in:
- lib/fusuma/plugin/detectors/detector.rb
Overview
Inherite this base
Direct Known Subclasses
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
: String.
-
#type ⇒ Object
readonly
: String.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_event(record:) ⇒ Events::Event
: (record: Fusuma::Plugin::Events::Records::IndexRecord) -> Fusuma::Plugin::Events::Event.
- #detect(_buffers) ⇒ Event, NilClass
-
#first_time? ⇒ Boolean
: () -> bool.
-
#initialize(*args) ⇒ Detector
constructor
: (*nil) -> void.
-
#last_time ⇒ Object
: () -> Time.
-
#sources ⇒ Array<String>
: () -> Array.
-
#watch? ⇒ TrueClass, FalseClass
Always watch buffers and detect them or not : () -> bool.
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins, #shutdown
Constructor Details
#initialize(*args) ⇒ Detector
: (*nil) -> void
16 17 18 19 20 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 16 def initialize(*args) super @tag = self.class.name.split("Detectors::").last.underscore @type = self.class.type(@tag) end |
Instance Attribute Details
#tag ⇒ Object (readonly)
: String
22 23 24 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 22 def tag @tag end |
#type ⇒ Object (readonly)
: String
23 24 25 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 23 def type @type end |
Class Method Details
.type(tag_name) ⇒ Object
11 12 13 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 11 def self.type(tag_name) tag_name.gsub("_detector", "") end |
Instance Method Details
#create_event(record:) ⇒ Events::Event
: (record: Fusuma::Plugin::Events::Records::IndexRecord) -> Fusuma::Plugin::Events::Event
50 51 52 53 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 50 def create_event(record:) @last_time = Time.now Events::Event.new(time: @last_time, tag: @tag, record: record) end |
#detect(_buffers) ⇒ Event, NilClass
41 42 43 44 45 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 41 def detect(_buffers) raise NotImplementedError, "override #{self.class.name}##{__method__}" # create_event(record:) end |
#first_time? ⇒ Boolean
: () -> bool
61 62 63 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 61 def first_time? @last_time.nil? end |
#last_time ⇒ Object
: () -> Time
56 57 58 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 56 def last_time @last_time ||= Time.now end |
#sources ⇒ Array<String>
: () -> Array
27 28 29 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 27 def sources @sources ||= self.class.const_get(:SOURCES) end |
#watch? ⇒ TrueClass, FalseClass
Always watch buffers and detect them or not : () -> bool
34 35 36 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 34 def watch? false end |