Class: CSV2Avro::AvroWriter
- Inherits:
-
Object
- Object
- CSV2Avro::AvroWriter
- Extended by:
- Forwardable
- Defined in:
- lib/csv2avro/avro_writer.rb
Instance Attribute Summary collapse
-
#avro_writer ⇒ Object
readonly
Returns the value of attribute avro_writer.
Instance Method Summary collapse
-
#initialize(writer, schema) ⇒ AvroWriter
constructor
A new instance of AvroWriter.
- #write(hash) ⇒ Object
- #writer_schema ⇒ Object
Constructor Details
#initialize(writer, schema) ⇒ AvroWriter
Returns a new instance of AvroWriter.
14 15 16 17 |
# File 'lib/csv2avro/avro_writer.rb', line 14 def initialize(writer, schema) datum_writer = CSV2Avro::DatumWriter.new(schema.avro_schema) @avro_writer = Avro::DataFile::Writer.new(writer, datum_writer, schema.avro_schema) end |
Instance Attribute Details
#avro_writer ⇒ Object (readonly)
Returns the value of attribute avro_writer.
9 10 11 |
# File 'lib/csv2avro/avro_writer.rb', line 9 def avro_writer @avro_writer end |
Instance Method Details
#write(hash) ⇒ Object
23 24 25 |
# File 'lib/csv2avro/avro_writer.rb', line 23 def write(hash) @avro_writer << hash end |
#writer_schema ⇒ Object
19 20 21 |
# File 'lib/csv2avro/avro_writer.rb', line 19 def writer_schema @avro_writer.datum_writer.writers_schema end |