Class: BerkeleyLibrary::TIND::Export::Exporter
- Inherits:
-
Object
- Object
- BerkeleyLibrary::TIND::Export::Exporter
- Includes:
- Logging
- Defined in:
- lib/berkeley_library/tind/export/exporter.rb
Overview
Superclass of exporters for different formats
Direct Known Subclasses
Instance Attribute Summary collapse
-
#collection ⇒ String
readonly
The collection name.
-
#exportable_only ⇒ Boolean
readonly
Whether to include only exportable fields.
Instance Method Summary collapse
-
#any_results? ⇒ Boolean
Returns true if the collection can be exported, false otherwise.
-
#export(out = nil) ⇒ Object
Exports the collection rubocop:disable Lint/UnusedMethodArgument.
-
#export_table ⇒ Export::Table
protected
Returns a table of all records in the specified collection.
-
#initialize(collection, exportable_only: true) ⇒ Exporter
constructor
Initializes a new exporter.
-
#respond_to?(*args) ⇒ Boolean
------------------------------------------------------------ Object overrides.
Constructor Details
#initialize(collection, exportable_only: true) ⇒ Exporter
Initializes a new exporter
29 30 31 32 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 29 def initialize(collection, exportable_only: true) @collection = collection @exportable_only = exportable_only end |
Instance Attribute Details
#collection ⇒ String (readonly)
Returns the collection name.
17 18 19 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 17 def collection @collection end |
#exportable_only ⇒ Boolean (readonly)
Returns whether to include only exportable fields.
20 21 22 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 20 def exportable_only @exportable_only end |
Instance Method Details
#any_results? ⇒ Boolean
Returns true if the collection can be exported, false otherwise. Note that this requires reading the collection data from the TIND server; failures will be fast but success may be slow. (On the other hand, the retrieved collection data is cached, so the subsequent export will not need to retrieve it again.)
55 56 57 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 55 def any_results? !_export_table.empty? end |
#export(out = nil) ⇒ Object
Exports the collection rubocop:disable Lint/UnusedMethodArgument
41 42 43 44 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 41 def export(out = nil) # This is a stub, used for documentation raise NoMethodError, "#{self.class} does not implement `export`" end |
#export_table ⇒ Export::Table (protected)
Returns a table of all records in the specified collection
78 79 80 81 82 83 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 78 def export_table # TODO: something more clever. Search.has_results? return _export_table unless _export_table.empty? raise no_results_error end |
#respond_to?(*args) ⇒ Boolean
Object overrides
62 63 64 65 66 |
# File 'lib/berkeley_library/tind/export/exporter.rb', line 62 def respond_to?(*args) return false if instance_of?(Exporter) && (args && args.first.to_s == 'export') super end |