Class: NWRFC::Table

Inherits:
DataContainer show all
Includes:
Enumerable, DataContainer
Defined in:
lib/nwrfc.old.rb,
lib/nwrfc.rb

Overview

Represents a table

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from NWRFC::DataContainer

Instance Method Details

#[](index) ⇒ Object

Retrieve the row at the given index



373
374
375
376
377
378
379
# File 'lib/nwrfc.rb', line 373

def [](index)
  rc = NWRFCLib.move_to(@handle, index, @error)
  NWRFC.check_error(@error) if rc > 0
  struct_handle = NWRFCLib.get_current_row(@handle, @error)
  NWRFC.check_error(@error)
  Structure.new(struct_handle)
end

#clearObject

Delete all rows from (empty) the table



367
368
369
370
# File 'lib/nwrfc.rb', line 367

def clear
  rc = delete_all_rows(@handle, @error)
  NWRFC.check_error(@error) if rc > 0
end

#each(&block) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
# File 'lib/nwrfc.rb', line 348

def each(&block)
  rc = NWRFCLib.move_to_first_row(@handle, @error)
  NWRFC.check_error(@error) if rc > 0
  size.times do |row|
    struct_handle = NWRFCLib.get_current_row(@handle, @error)
    NWRFC.check_error(@error)
    # CAVEAT: Other calls using the handle require "handle" field
    # of the RFC_DATA_CONTAINER struct
    yield Structure.new(struct_handle)
  end
end

#sizeObject



360
361
362
363
364
# File 'lib/nwrfc.rb', line 360

def size
  rows = FFI::MemoryPointer.new(:uint)
  rc = NWRFCLib.get_row_count(@handle, rows, @error)
  rows.read_uint
end