Class: Embulk::Page

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/embulk/page.rb

Overview

TODO pure-ruby page reader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(java_page, schema) ⇒ Page

Returns a new instance of Page.



9
10
11
12
# File 'lib/embulk/page.rb', line 9

def initialize(java_page, schema)
  @java_page = java_page
  @schema = schema
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



14
15
16
# File 'lib/embulk/page.rb', line 14

def schema
  @schema
end

Instance Method Details

#eachObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/embulk/page.rb', line 16

def each
  schema = @schema
  reader = Java::PageReader.new(schema.to_java)
  begin
    reader.setPage(@java_page)
    while reader.nextRecord
      yield schema.read_record(reader)
    end
  ensure
    reader.close
  end
end