Class: Feedx::Format::Parquet::Decoder

Inherits:
Abstract::Decoder show all
Defined in:
lib/feedx/format/parquet.rb

Instance Method Summary collapse

Methods inherited from Abstract::Decoder

#close, #decode_each

Methods inherited from Abstract::Wrapper

open

Constructor Details

#initialize(io) ⇒ Decoder

Returns a new instance of Decoder.



14
15
16
17
18
19
# File 'lib/feedx/format/parquet.rb', line 14

def initialize(io, **)
  super(io)

  @table  = read_table
  @cursor = 0
end

Instance Method Details

#decode(target) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/feedx/format/parquet.rb', line 25

def decode(target, **)
  return if eof?

  rec = Record.new(@table, @cursor)
  @cursor += 1

  target = target.allocate if target.is_a?(Class)
  target.from_parquet(rec)
  target
end

#eof?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/feedx/format/parquet.rb', line 21

def eof?
  @cursor >= @table.n_rows
end