Class: OfflineSort::Chunk::InputOutput::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/offline_sort/chunk/input_output/yaml.rb

Constant Summary

Constants inherited from Base

Base::MethodNotImplementedError

Instance Attribute Summary

Attributes inherited from Base

#io

Instance Method Summary collapse

Methods inherited from Base

#close, #each, #flush, #initialize, #rewind, #write_entries

Constructor Details

This class inherits a constructor from OfflineSort::Chunk::InputOutput::Base

Instance Method Details

#read_entryObject

The yaml parser does not expose a document enumerator that we can call next on without loading the entire file



10
11
12
# File 'lib/offline_sort/chunk/input_output/yaml.rb', line 10

def read_entry
  YAML.load(next_document) # rubocop:disable Security/YAMLLoad, this is loading from a trusted source
end

#write_entry(entry) ⇒ Object



14
15
16
# File 'lib/offline_sort/chunk/input_output/yaml.rb', line 14

def write_entry(entry)
  io.write(YAML.dump(entry))
end