Class: MDB

Inherits:
Object
  • Object
show all
Includes:
MDBTools
Defined in:
lib/active_mdb/mdb.rb

Overview

require ‘mdb_tools’

Constant Summary

Constants included from MDBTools

MDBTools::BACKENDS, MDBTools::DELIMITER, MDBTools::LINEBREAK, MDBTools::SANITIZER

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @mdb_file = check_file(mdb_file)
  @prefix = options[:prefix] || ''
  @exclude, @include = options[:exclude], options[:include]
  @export_syntax = options[:sql_syntax] || 'mysql'
  @tables = mdb_tables(@mdb_file, :exclude => @exclude, :include => @include)
  # @tables = create_table_objects
end

Instance Attribute Details

#excludeObject (readonly)

Returns the value of attribute exclude.



6
7
8
# File 'lib/active_mdb/mdb.rb', line 6

def exclude
  @exclude
end

#mdb_fileObject (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

#prefixObject (readonly)

Returns the value of attribute prefix.



6
7
8
# File 'lib/active_mdb/mdb.rb', line 6

def prefix
  @prefix
end

#tablesObject (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