Class: Fluent::Plugin::Logcheck::RuleSet
- Inherits:
-
Object
- Object
- Fluent::Plugin::Logcheck::RuleSet
- Extended by:
- T::Sig
- Defined in:
- lib/fluent/plugin/logcheck/rule.rb
Overview
Collection of rules of the same type from a source
Instance Attribute Summary collapse
- #rules ⇒ Array<Rule> readonly
- #source_path ⇒ String readonly
- #type ⇒ Symbol readonly
Instance Method Summary collapse
-
#add_rule(rule)
Add rule to set.
-
#empty? ⇒ Boolean
Check if rule set is empty.
-
#initialize(type, source_path)
constructor
Initialize rule set.
-
#match(text) ⇒ Rule?
Find first matching rule.
-
#match_all(text) ⇒ Array<Rule>
Find all matching rules.
-
#size ⇒ Integer
Get rule count.
Constructor Details
#initialize(type, source_path)
Initialize rule set
118 119 120 121 122 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 118 def initialize(type, source_path) @type = type @source_path = source_path @rules = T.let([], T::Array[Rule]) end |
Instance Attribute Details
#rules ⇒ Array<Rule> (readonly)
106 107 108 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 106 def rules @rules end |
#source_path ⇒ String (readonly)
112 113 114 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 112 def source_path @source_path end |
#type ⇒ Symbol (readonly)
109 110 111 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 109 def type @type end |
Instance Method Details
#add_rule(rule)
This method returns an undefined value.
Add rule to set
127 128 129 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 127 def add_rule(rule) @rules << rule end |
#empty? ⇒ Boolean
Check if rule set is empty
157 158 159 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 157 def empty? @rules.empty? end |
#match(text) ⇒ Rule?
Find first matching rule
135 136 137 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 135 def match(text) @rules.find { |rule| rule.match?(text) } end |
#match_all(text) ⇒ Array<Rule>
Find all matching rules
143 144 145 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 143 def match_all(text) @rules.filter { |rule| rule.match?(text) } end |
#size ⇒ Integer
Get rule count
150 151 152 |
# File 'lib/fluent/plugin/logcheck/rule.rb', line 150 def size @rules.size end |