Class KirbyBase::KBTable
In: lib/kirbybase.rb
Parent: Object

Methods

Included Modules

DRb::DRbUndumped KBTypeConversionsMixin

Classes and Modules

Class KirbyBase::KBTable::KBBlob
Class KirbyBase::KBTable::KBIndex
Class KirbyBase::KBTable::KBMemo
Class KirbyBase::KBTable::KBRecnoIndex
Class KirbyBase::KBTable::KBResultSet
Class KirbyBase::KBTable::KBTableRec

Constants

VALID_FIELD_TYPES = [:String, :Integer, :Float, :Boolean, :Date, :Time, :DateTime, :Memo, :Blob, :ResultSet, :YAML]   Make constructor private. KBTable instances should only be created from KirbyBase#get_table.
VALID_DEFAULT_TYPES = [:String, :Integer, :Float, :Boolean, :Date, :Time, :DateTime, :YAML]
VALID_INDEX_TYPES = [:String, :Integer, :Float, :Boolean, :Date, :Time, :DateTime]

External Aliases

clear -> delete_all
  Alias delete_all to clear method.

Attributes

db  [R] 
filename  [R] 
lookup_key  [R] 
name  [R] 
table_class  [R] 

Public Class methods

Return a new instance of KBTable. Should never be called directly by your application. Should only be called from KirbyBase#get_table.

This has been declared private so user‘s cannot create new instances of KBTable from their application. A user gets a handle to a KBTable instance by calling KirbyBase#get_table for an existing table or KirbyBase.create_table for a new table.

Return true if data is correct type, false otherwise.

data_type:Symbol specifying data type.
value:Value to convert to String.

Return true if valid default type.

field_type:Symbol specifying field type.

Return true if valid field type.

field_type:Symbol specifying field type.

Return true if valid index type.

field_type:Symbol specifying field type.

Public Instance methods

Return the record(s) whose recno field is included in index.

index:Array of Integer(s) specifying recno(s) you wish to select.

Update record whose recno field equals index.

index:Integer specifying recno you wish to select.
updates:Hash, Struct, or Array containing updates.

Add a column to table.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_name:Symbol of column name to add.
col_type:Symbol (or Hash if includes field extras) of column type to add.
after:Symbol of column name that you want to add this column after.

Add an index to a column.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_names:Array containing column name(s) of new index.

Change a column‘s default value.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_name:Symbol of column name.
value:New default value for column.

Change whether a column is required.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_name:Symbol of column name.
required:true or false.

Change a column‘s type.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_name:Symbol of column name.
col_type:Symbol of new column type.

Delete all records from table. You can also use delete_all.

reset_recno_ctr:true/false specifying whether recno counter should be reset to 0.

Delete records from table and return # deleted.

select_cond:Proc containing code to select records.

Drop a column from table.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_name:Symbol of column name to add.

Drop an index on a column(s).

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

col_names:Array containing column name(s) of new index.

Returns true if table is encrypted.

Return array containing table field defaults.

Return array containing table field extras.

Return array containing table field indexes.

Return array containing table field names.

Return array containing table field requireds.

Return array containing table field types.

Import csv file into table.

csv_filename:filename of csv file to import.

Insert a new record into a table, return unique record number.

data:Array, Hash, Struct instance containing field values of new record.
insert_proc:Proc instance containing insert code. This and the data parameter are mutually exclusive.

Remove blank records from table, return total removed.

Rename a column.

Make sure you are executing this method while in single-user mode (i.e. not running in client/server mode).

old_col_name:Symbol of old column name.
new_col_name:Symbol of new column name.

Return array of records (Structs) matching select conditions.

filter:List of field names (Symbols) to include in result set.
select_cond:Proc containing select code.

Return array of records (Structs) matching select conditions. Select condition block should not contain references to any table column except :recno. If you need to select by other table columns than just :recno, use select instead.

filter:List of field names (Symbols) to include in result set.
select_cond:Proc containing select code.

Set fields of records to updated values. Returns number of records updated.

recs:Array of records (Structs) that will be updated.
data:Hash, Struct, Proc containing updates.

Return total number of undeleted (blank) records in table.

Return array of records (Structs) to be updated based on select cond.

updates:Hash or Struct containing updates.
select_cond:Proc containing code to select records to update.

Return array of records (Structs) to be updated, in this case all records.

updates:Hash or Struct containing updates.

[Validate]