Module: BerkeleyLibrary::TIND::Export

Defined in:
lib/berkeley_library/tind/export/row.rb,
lib/berkeley_library/tind/export/table.rb,
lib/berkeley_library/tind/export/column.rb,
lib/berkeley_library/tind/export/config.rb,
lib/berkeley_library/tind/export/export.rb,
lib/berkeley_library/tind/export/filter.rb,
lib/berkeley_library/tind/export/exporter.rb,
lib/berkeley_library/tind/export/row_metrics.rb,
lib/berkeley_library/tind/export/column_group.rb,
lib/berkeley_library/tind/export/csv_exporter.rb,
lib/berkeley_library/tind/export/ods_exporter.rb,
lib/berkeley_library/tind/export/export_format.rb,
lib/berkeley_library/tind/export/table_metrics.rb,
lib/berkeley_library/tind/export/export_command.rb,
lib/berkeley_library/tind/export/export_exception.rb,
lib/berkeley_library/tind/export/no_results_error.rb,
lib/berkeley_library/tind/export/column_group_list.rb,
lib/berkeley_library/tind/export/column_width_calculator.rb

Defined Under Namespace

Modules: ColumnWidthCalculator, Config, Filter Classes: CSVExporter, Column, ColumnGroup, ColumnGroupList, ExportCommand, ExportException, ExportFormat, Exporter, NoResultsError, ODSExporter, Row, RowMetrics, Table, TableMetrics

Class Method Summary collapse

Class Method Details

.export(collection, format = ExportFormat::CSV) ⇒ Object .export(collection, format = ExportFormat::CSV, out) ⇒ Object .export(collection, format = ExportFormat::CSV, path) ⇒ Object

Writes a spreadsheet in the specified format

Overloads:

  • .export(collection, format = ExportFormat::CSV) ⇒ Object

    Returns the spreadsheet as a string.

    Parameters:

    • collection (String)

      The collection name

    • format (ExportFormat, String, Symbol) (defaults to: ExportFormat::CSV)

      the export format

    • exportable_only (Boolean)

      whether to include only exportable fields

  • .export(collection, format = ExportFormat::CSV, out) ⇒ Object

    Writes the spreadsheet to the specified output stream.

    Parameters:

    • collection (String)

      The collection name

    • format (ExportFormat, String, Symbol) (defaults to: ExportFormat::CSV)

      the export format

    • out (IO)

      the output stream

    • exportable_only (Boolean)

      whether to include only exportable fields

  • .export(collection, format = ExportFormat::CSV, path) ⇒ Object

    Writes the spreadsheet to the specified output file.

    Parameters:

    • collection (String)

      The collection name

    • format (ExportFormat, String, Symbol) (defaults to: ExportFormat::CSV)

      the export format

    • path (String, Pathname)

      the path to the output file

    • exportable_only (Boolean)

      whether to include only exportable fields

Raises:

  • (ExportFailed)

    if the collection does not exist, or cannot be exported. Note that this error is guaranteed to be raised before anything is written to out.



27
28
29
30
31
# File 'lib/berkeley_library/tind/export/export.rb', line 27

def export(collection, format = ExportFormat::CSV, out = nil, exportable_only: true)
  # noinspection RubyYardParamTypeMatch
  exporter = exporter_for(collection, format, exportable_only: exportable_only)
  exporter.export(out)
end

.exporter_for(collection, format, exportable_only: true) ⇒ Exporter

Returns an exporter for the specified spreadsheet in the specified format

Parameters:

  • collection (String)

    The collection name

  • format (ExportFormat, String, Symbol)

    the export format

  • exportable_only (Boolean) (defaults to: true)

    whether to include only exportable fields

Returns:



38
39
40
41
42
# File 'lib/berkeley_library/tind/export/export.rb', line 38

def exporter_for(collection, format, exportable_only: true)
  export_format = ExportFormat.ensure_format(format)
  # noinspection RubyNilAnalysis
  export_format.exporter_for(collection, exportable_only: exportable_only)
end