Class: Embulk::Page

Inherits:
Object
  • Object
show all
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.



7
8
9
10
# File 'lib/embulk/page.rb', line 7

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

Instance Attribute Details

#schema ⇒ Object (readonly)

Returns the value of attribute schema.



12
13
14
# File 'lib/embulk/page.rb', line 12

def schema
  @schema
end

Instance Method Details

#each ⇒ Object



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

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