Class: MDB
Overview
require ‘mdb_tools’
Constant Summary
Constants included from MDBTools
MDBTools::BACKENDS, MDBTools::DELIMITER, MDBTools::LINEBREAK, MDBTools::SANITIZER
Instance Attribute Summary collapse
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#mdb_file ⇒ Object
readonly
Returns the value of attribute mdb_file.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
- #column_names(table_name) ⇒ Object
- #columns(table_name) ⇒ Object
-
#count(table_name, attribute) ⇒ Object
consumer of poor, weak MDBTools.faked_count.
-
#initialize(mdb_file, options = {}) ⇒ MDB
constructor
A new instance of MDB.
Methods included from MDBTools
#arrays_to_hashes, #backends, #check_file, #check_table, #compile_conditions, #delimited_to_arrays, #describe_table, #faked_count, #field_names_for, #mdb_export, #mdb_schema, #mdb_sql, #mdb_tables, #mdb_truth, #mdb_version, #methodize, #sanitize!, #sql_select_where, #table_to_csv, #valid_file?
Constructor Details
#initialize(mdb_file, options = {}) ⇒ MDB
Returns a new instance of MDB.
8 9 10 11 12 13 14 15 |
# File 'lib/active_mdb/mdb.rb', line 8 def initialize(mdb_file, = {}) @mdb_file = check_file(mdb_file) @prefix = [:prefix] || '' @exclude, @include = [:exclude], [:include] @export_syntax = [:sql_syntax] || 'mysql' @tables = mdb_tables(@mdb_file, :exclude => @exclude, :include => @include) # @tables = create_table_objects end |
Instance Attribute Details
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
6 7 8 |
# File 'lib/active_mdb/mdb.rb', line 6 def exclude @exclude end |
#mdb_file ⇒ Object (readonly)
Returns the value of attribute mdb_file.
6 7 8 |
# File 'lib/active_mdb/mdb.rb', line 6 def mdb_file @mdb_file end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/active_mdb/mdb.rb', line 6 def prefix @prefix end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
6 7 8 |
# File 'lib/active_mdb/mdb.rb', line 6 def tables @tables end |
Instance Method Details
#column_names(table_name) ⇒ Object
28 29 30 |
# File 'lib/active_mdb/mdb.rb', line 28 def column_names(table_name) MDBTools.field_names_for(@mdb_file, table_name) end |
#columns(table_name) ⇒ Object
22 23 24 25 26 |
# File 'lib/active_mdb/mdb.rb', line 22 def columns(table_name) MDBTools.describe_table(@mdb_file, table_name).map do |column| Column.new_from_describe(column) end end |
#count(table_name, attribute) ⇒ Object
consumer of poor, weak MDBTools.faked_count
18 19 20 |
# File 'lib/active_mdb/mdb.rb', line 18 def count(table_name, attribute) MDBTools.faked_count(@mdb_file, table_name, attribute) end |