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.
-
#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
Constructor Details
#initialize(*args) ⇒ Buffer
Returns a new instance of Buffer.
10 11 12 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 10 def initialize(*args) @events = Array.new(*args) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
14 15 16 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 14 def events @events end |
Instance Method Details
#buffer(event) ⇒ Object
22 23 24 25 26 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 22 def buffer(event) return if event&.tag != source @events.push(event) end |
#clear ⇒ Object
clear buffer
29 30 31 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 29 def clear @events.clear end |
#source ⇒ Object
Set source for tag from config.yml. DEFAULT_SOURCE is defined in each plugins.
35 36 37 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 35 def source @source ||= config_params(:source) || self.class.const_get('DEFAULT_SOURCE') end |
#type ⇒ String
17 18 19 |
# File 'lib/fusuma/plugin/buffers/buffer.rb', line 17 def type self.class.name.underscore.split('/').last.gsub('_buffer', '') end |