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
-
.type(tag_name) ⇒ Object
: (String) -> String.
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
17 18 19 20 21 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 17 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
23 24 25 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 23 def tag @tag end |
#type ⇒ Object (readonly)
: String
24 25 26 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 24 def type @type end |
Class Method Details
.type(tag_name) ⇒ Object
: (String) -> String
12 13 14 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 12 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
51 52 53 54 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 51 def create_event(record:) @last_time = Time.now Events::Event.new(time: @last_time, tag: @tag, record: record) end |
#detect(_buffers) ⇒ Event, NilClass
42 43 44 45 46 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 42 def detect(_buffers) raise NotImplementedError, "override #{self.class.name}##{__method__}" # create_event(record:) end |
#first_time? ⇒ Boolean
: () -> bool
62 63 64 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 62 def first_time? @last_time.nil? end |
#last_time ⇒ Object
: () -> Time
57 58 59 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 57 def last_time @last_time ||= Time.now end |
#sources ⇒ Array<String>
: () -> Array
28 29 30 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 28 def sources @sources ||= self.class.const_get(:SOURCES) end |
#watch? ⇒ TrueClass, FalseClass
Always watch buffers and detect them or not : () -> bool
35 36 37 |
# File 'lib/fusuma/plugin/detectors/detector.rb', line 35 def watch? false end |