Class: TrajectPlus::JsonReader
- Inherits:
-
Object
- Object
- TrajectPlus::JsonReader
- Defined in:
- lib/traject_plus/json_reader.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(input_stream, settings) ⇒ JsonReader
constructor
A new instance of JsonReader.
Constructor Details
#initialize(input_stream, settings) ⇒ JsonReader
Returns a new instance of JsonReader.
8 9 10 11 12 |
# File 'lib/traject_plus/json_reader.rb', line 8 def initialize(input_stream, settings) @settings = Traject::Indexer::Settings.new settings @input_stream = input_stream @json = JSON.parse(input_stream.read) end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
14 15 16 |
# File 'lib/traject_plus/json_reader.rb', line 14 def json @json end |
Instance Method Details
#each(&block) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/traject_plus/json_reader.rb', line 16 def each(&block) return to_enum(:each) unless block_given? if json.is_a? Array json.each(&block) else yield json end end |