Class: JSE::Stream::FilterChain

Inherits:
Object
  • Object
show all
Defined in:
lib/jse/stream.rb

Instance Method Summary collapse

Constructor Details

#initialize(filters) ⇒ FilterChain

Returns a new instance of FilterChain.



83
84
85
# File 'lib/jse/stream.rb', line 83

def initialize(filters)
  @filters = filters
end

Instance Method Details

#eliminates?(line) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
95
96
# File 'lib/jse/stream.rb', line 87

def eliminates?(line)
  begin
    json = JSON.parse(line)
    !@filters.all?{ |f| f.match?(json) }
  rescue JSON::ParserError
    $stderr.puts "Error parsing line:"
    $stderr.puts line
    true
  end
end