Class: NDJSON::Parser
- Inherits:
-
Object
- Object
- NDJSON::Parser
- Defined in:
- lib/ndjson.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(input) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(input) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 13 |
# File 'lib/ndjson.rb', line 7 def initialize input @input = if input.is_a? String open(input) else input end end |
Instance Method Details
#each(&block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ndjson.rb', line 15 def each &block @input.each do |line| json_line = JSON.parse(line) yield json_line end end |