Class: NWRFC::Table
- Inherits:
-
DataContainer
- Object
- DataContainer
- NWRFC::Table
- Includes:
- Enumerable
- Defined in:
- lib/nwrfc.rb
Instance Attribute Summary
Attributes inherited from DataContainer
Instance Method Summary collapse
-
#[](index) ⇒ Object
Retrieve the row at the given index.
-
#append(row) ⇒ Object
Append a row (structure) to the table.
-
#clear ⇒ Object
Delete all rows from (empty) the table.
-
#each(&block) ⇒ Object
Iterate over the rows in a table.
-
#new_row ⇒ Object
Add new (empty) row and return the structure handle or yield it to a passed block.
-
#size ⇒ Object
Return the number of rows in the table.
Methods inherited from DataContainer
#[]=, #fields, #initialize, #member_metadata, #value_to_date, #value_to_time
Constructor Details
This class inherits a constructor from NWRFC::DataContainer
Instance Method Details
#[](index) ⇒ Object
Retrieve the row at the given index
349 350 351 352 353 354 355 |
# File 'lib/nwrfc.rb', line 349 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) ⇒ Object
Append a row (structure) to the table
358 359 360 361 362 |
# File 'lib/nwrfc.rb', line 358 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 ⇒ Object
Delete all rows from (empty) the table
343 344 345 346 |
# File 'lib/nwrfc.rb', line 343 def clear rc = delete_all_rows(@handle, @error) NWRFC.check_error(@error) if rc > 0 end |
#each(&block) ⇒ Object
Iterate over the rows in a table. Each row is yielded as a structure
322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/nwrfc.rb', line 322 def each(&block) #:yields row 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 ⇒ Object
Add new (empty) row and return the structure handle or yield it to a passed block
367 368 369 370 371 372 373 374 375 376 |
# File 'lib/nwrfc.rb', line 367 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 |