Class: JSE::Stream::TransformChain
- Inherits:
-
Object
- Object
- JSE::Stream::TransformChain
- Defined in:
- lib/jse/stream.rb
Instance Method Summary collapse
- #apply(line) ⇒ Object
-
#initialize(transforms) ⇒ TransformChain
constructor
A new instance of TransformChain.
Constructor Details
#initialize(transforms) ⇒ TransformChain
Returns a new instance of TransformChain.
58 59 60 |
# File 'lib/jse/stream.rb', line 58 def initialize(transforms) @transforms = transforms end |
Instance Method Details
#apply(line) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jse/stream.rb', line 62 def apply(line) begin if @transforms.empty? line else json = JSON.parse(line) @transforms.inject(json){ |j, transform| transform.apply(j) } end rescue JSON::ParserError $stderr.puts "Error parsing line:" $stderr.puts line true end end |