Class: Fusuma::Plugin::Buffers::Buffer
- Inherits:
-
Fusuma::Plugin::Base
- Object
- Fusuma::Plugin::Base
- Fusuma::Plugin::Buffers::Buffer
- Defined in:
- lib/fusuma/plugin/buffers/buffer.rb
Overview
buffer events and output
Direct Known Subclasses
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #buffer(event) ⇒ Object
-
#clear ⇒ Object
clear buffer.
-
#clear_expired(current_time: Time.now) ⇒ Object
clear old events.
-
#initialize(*args) ⇒ Buffer
constructor
A new instance of Buffer.
-
#source ⇒ Object
Set source for tag from config.yml.
- #type ⇒ String
Methods inherited from Fusuma::Plugin::Base
#config_index, #config_param_types, #config_params, inherited, plugins
Methods included from CustomProcess
Constructor Details
#initialize(*args) ⇒ Buffer
Returns a new instance of Buffer.
10 11 12 13 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 10 def initialize(*args) super() @events = Array.new(*args) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
15 16 17 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 15 def events @events end |
Instance Method Details
#buffer(event) ⇒ Object
23 24 25 26 27 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 23 def buffer(event) return if event&.tag != source @events.push(event) end |
#clear ⇒ Object
clear buffer
34 35 36 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 34 def clear @events.clear end |
#clear_expired(current_time: Time.now) ⇒ Object
clear old events
31 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 31 def clear_expired(current_time: Time.now); end |
#source ⇒ Object
Set source for tag from config.yml. DEFAULT_SOURCE is defined in each plugins.
40 41 42 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 40 def source @source ||= config_params(:source) || self.class.const_get('DEFAULT_SOURCE') end |
#type ⇒ String
18 19 20 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 18 def type @type ||= self.class.name.underscore.split('/').last.gsub('_buffer', '') end |