Module: NERA
- Defined in:
- lib/nera/nera_cui.rb,
lib/nera.rb,
lib/nera/nera_database.rb,
lib/nera/nera_simulator.rb,
lib/nera/nera_db_folders.rb,
lib/nera/nera_job_script.rb,
lib/nera/nera_job_records.rb,
lib/nera/nera_run_records.rb,
lib/nera_addhost/add_hosts.rb,
lib/nera/nera_remote_connector.rb,
lib/nera_addsim/make_simulator.rb,
lib/nera/nera_parameter_records.rb,
lib/nera/nera_simulator_records.rb,
lib/nera/nera_job_layer_controller.rb,
lib/nera/nera_run_layer_controller.rb,
lib/nera/nera_parameter_layer_controller.rb,
lib/nera/nera_simulator_layer_controller.rb
Overview
- list of public methods
-
initialize( path_to_filename )
-
self.create_table( path_to_basename ) --- method to create new table --- ex. NERA::Database.create_table( "./db")
-
add( new_rec ) --- add a new record to the table. --- new_rec must be specified by a Hash. --- ex. db.add( { :key1 => 'test', :key2 => DateTime.now, ... } ) --- You don't need to specify the ':id' key. If it is specified, it is omitted. --- During the transaction, files are locked with exclusive locks. --- return true if the addition succeeded. --- raise RuntimeError if the specified hash is not valid.
-
find_by_id( id ) --- returns records in Hash. --- id can be Integer, Array of Integers, or Range of Integers. --- During reading file, the files are locked with shared locks. --- If there are several records, it returns Array of Hash.
-
find_all { |rec| (condition) } --- returns the array of the matched records. --- return nil if no record matched.
-
update( rec ) --- update a record --- ex. db.update( :key1=>'updated', :key2=>DateTime.now ) --- returns nil if the record of the specified 'id' does not exist.
-
destroy( id ) --- destroy records --- id may be an Integer, Array of Integers, Range --- if the specified record is not found in the table, return nil.
-
transaction { ..(transaction).. } --- all the database files are exclusively locked during block is processed. --- database files are unlocked at the end of the block. terminates. --- sample -----------
db.transaction do arr = db.find_all do |record| record > 5 end
arr.each do |rec| rec[:state] = finished end
db.update( arr)
end
--- end of sample ---
Defined Under Namespace
Classes: CUI_Hosts_Editor, CUI_Simulator_Adder, CUI_exec, Database, DbFolders, JobLayerController, JobRecords, JobScript, ParameterLayerController, ParameterRecords, RemoteConnector, RunLayerController, RunRecords, Simulator, SimulatorLayerController, SimulatorRecords
Constant Summary collapse
- VERSION =
'0.7.0'