Module: Tabledata

Defined in:
lib/tabledata.rb,
lib/tabledata/row.rb,
lib/tabledata/table.rb,
lib/tabledata/tables.rb,
lib/tabledata/column.rb,
lib/tabledata/parser.rb,
lib/tabledata/version.rb,
lib/tabledata/coercion.rb,
lib/tabledata/detection.rb,
lib/tabledata/presenter.rb,
lib/tabledata/exceptions.rb,
lib/tabledata/coerced_row.rb,
lib/tabledata/custom_table.rb,
lib/tabledata/presenters/csv.rb,
lib/tabledata/presenters/pdf.rb,
lib/tabledata/presenters/html.rb,
lib/tabledata/table_definition.rb,
lib/tabledata/presenters/excel.rb,
lib/tabledata/column_definition.rb,
lib/tabledata/dsls/table_definition.rb

Overview

Handle tabular data

Tabledata supports the following file formats:

  • .xls Excel files (:xls)
  • .xlsx Excel files (:xlsx)
  • .csv Comma Separated Values (:csv)

Defined Under Namespace

Modules: Coercion, Detection, Dsls, Exception, Parser, Presenters Classes: CoercedRow, Column, ColumnDefinition, CustomTable, InvalidColumnAccessor, InvalidColumnCount, InvalidColumnName, InvalidColumnSpecifier, InvalidFileType, InvalidOptions, LibraryMissingError, Presenter, Row, Table, TableDefinition, Tables

Constant Summary collapse

Version =

The version of the tabledata gem.

Gem::Version.new("0.0.3")

Class Method Summary collapse

Class Method Details

.define_table(*args, &block) ⇒ Object


55
56
57
# File 'lib/tabledata.rb', line 55

def define_table(*args, &block)
  Dsls::TableDefinition.new(*args, &block).definition.create_table_class
end

.table(options) ⇒ Tabledata::Table

If a :file option is present, it uses #Tabledata::Table.from_file, otherwise #Tabledata::Table.new.


26
27
28
29
30
31
32
33
34
35
# File 'lib/tabledata.rb', line 26

def table(options)
  if options.has_key?(:file)
    options = options.dup
    path   = options.delete(:file)

    Table.from_file(path, options)
  else
    Table.new(options)
  end
end

.tables(options) ⇒ Tabledata::Tables

If a :file option is present, it uses #Tabledata::Table.from_file, otherwise #Tabledata::Tables.new.


44
45
46
47
48
49
50
51
52
53
# File 'lib/tabledata.rb', line 44

def tables(options)
  if options.has_key?(:file)
    options = options.dup
    path   = options.delete(:file)

    Tables.from_file(path, options)
  else
    Tables.new(options)
  end
end