Class: StreamLines::Reading::JSONLines

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/stream_lines/reading/json_lines.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, encoding: Encoding.default_external, **json_options) ⇒ JSONLines

Returns a new instance of JSONLines.



11
12
13
14
15
# File 'lib/stream_lines/reading/json_lines.rb', line 11

def initialize(url, encoding: Encoding.default_external, **json_options)
  @url = url
  @json_options = json_options
  @stream = Stream.new(url, encoding: encoding)
end

Instance Method Details

#each(&block) ⇒ Object



17
18
19
# File 'lib/stream_lines/reading/json_lines.rb', line 17

def each(&block)
  @stream.each { |line| block.call(parse_line(line)) }
end