Class: FlatKit::Jsonl::Reader
- Defined in:
- lib/flat_kit/jsonl/reader.rb
Overview
Internal: Reader class that parses and yields records from JSONL files
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Attributes inherited from Reader
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(source:, compare_fields: :none) ⇒ Reader
constructor
A new instance of Reader.
Methods inherited from Reader
create_reader_from_path, create_readers_from_paths, #format_name
Constructor Details
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
8 9 10 |
# File 'lib/flat_kit/jsonl/reader.rb', line 8 def count @count end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/flat_kit/jsonl/reader.rb', line 8 def input @input end |
Class Method Details
.format_name ⇒ Object
10 11 12 |
# File 'lib/flat_kit/jsonl/reader.rb', line 10 def self.format_name ::FlatKit::Jsonl::Format.format_name end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flat_kit/jsonl/reader.rb', line 20 def each while (line = input.io.gets) record = ::FlatKit::Jsonl::Record.new(data: line, compare_fields: compare_fields) @count += 1 yield record end input.close rescue StandardError => e ::FlatKit.logger.error "Error reading jsonl records from #{input.name}: #{e}" raise ::FlatKit::Error, e end |