class NWRFC::Table
Public Instance Methods
[](index)
click to toggle source
Retrieve the row at the given index
# File lib/nwrfc.rb, line 386 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
append(row)
click to toggle source
Append a row (structure) to the table
# File lib/nwrfc.rb, line 395 def append(row) raise "Must append a structure" unless row.class == NWRFC::Structure rc = NWRFCLib.append_row(@handle, row.handle, @error) NWRFC.check_error(@error) if rc > 0 end
clear()
click to toggle source
Delete all rows from (empty) the table
# File lib/nwrfc.rb, line 380 def clear rc = NWRFCLib.delete_all_rows(@handle, @error) NWRFC.check_error(@error) if rc > 0 end
each() { |structure| ... }
click to toggle source
Iterate over the rows in a table. Each row is yielded as a structure
# File lib/nwrfc.rb, line 358 def each(&block) #:yields row return [] if size == 0 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) NWRFCLib.move_to_next_row(@handle, @error) # CAVEAT: Other calls using the handle require "handle" field # of the RFC_DATA_CONTAINER struct yield Structure.new(struct_handle) end end
new_row() { |s| ... }
click to toggle source
Add new (empty) row and return the structure handle or yield it to a passed block @return Structure
# File lib/nwrfc.rb, line 404 def new_row s_handle = NWRFCLib.append_new_row(@handle, @error) NWRFC.check_error(@error) s = Structure.new(s_handle) if block_given? yield s else s end end
size()
click to toggle source
Return the number of rows in the table
# File lib/nwrfc.rb, line 373 def size rows = FFI::MemoryPointer.new(:uint) rc = NWRFCLib.get_row_count(@handle, rows, @error) rows.read_uint end