Class: Fluent::InlineClassifierOutput::RangeClassifier

Inherits:
Classifier
  • Object
show all
Defined in:
lib/fluent/plugin/out_inline_classifier.rb

Instance Attribute Summary

Attributes inherited from Classifier

#key, #rules, #store

Instance Method Summary collapse

Methods inherited from Classifier

#classify, #run!

Constructor Details

#initialize(key, store, rules) ⇒ RangeClassifier

Returns a new instance of RangeClassifier.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_inline_classifier.rb', line 35

def initialize(key, store, rules)
  super
  @rules = []
  rules.each {|name, args|
    args = args.split()
    from = args[0].to_f
    to = args[1].to_f

    if args[0] == '*'
      func = lambda {|v| v.to_f < to}
    elsif args[1] == '*'
      func = lambda {|v| from <= v.to_f}
    else
      func = lambda {|v| v = v.to_f; from <= v and v < to}
    end

    @rules << [name, func]
  }
end