Class: Fusuma::Plugin::Detectors::Detector
- Inherits:
-
Base
- Object
- Base
- Fusuma::Plugin::Detectors::Detector
show all
- Defined in:
- lib/fusuma/plugin/detectors/detector.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins, #shutdown
Constructor Details
#initialize(*args) ⇒ Detector
Returns a new instance of Detector.
11
12
13
14
15
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 11
def initialize(*args)
super
@tag = self.class.tag
@type = self.class.type
end
|
Instance Attribute Details
#tag ⇒ Object
Returns the value of attribute tag.
17
18
19
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 17
def tag
@tag
end
|
#type ⇒ Object
Returns the value of attribute type.
18
19
20
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 18
def type
@type
end
|
Class Method Details
.tag ⇒ Object
56
57
58
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 56
def tag
name.split("Detectors::").last.underscore
end
|
.type(tag_name = tag) ⇒ Object
60
61
62
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 60
def type(tag_name = tag)
tag_name.gsub("_detector", "")
end
|
Instance Method Details
42
43
44
45
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 42
def create_event(record:)
@last_time = Time.now
Events::Event.new(time: @last_time, tag: tag, record: record)
end
|
#detect(_buffers) ⇒ Event, NilClass
34
35
36
37
38
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 34
def detect(_buffers)
raise NotImplementedError, "override #{self.class.name}##{__method__}"
end
|
#first_time? ⇒ Boolean
51
52
53
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 51
def first_time?
@last_time.nil?
end
|
#last_time ⇒ Object
47
48
49
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 47
def last_time
@last_time ||= Time.now
end
|
#sources ⇒ Array<String>
21
22
23
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 21
def sources
@sources ||= self.class.const_get(:SOURCES)
end
|
#watch? ⇒ TrueClass, FalseClass
Always watch buffers and detect them or not
27
28
29
|
# File 'lib/fusuma/plugin/detectors/detector.rb', line 27
def watch?
false
end
|