Class: DS::Source::BaseSource

Inherits:
Object
  • Object
show all
Includes:
SourceCache
Defined in:
lib/ds/source/base_source.rb

Overview

Encapsulates methods for caching and opening source files.

This class includes the DS::Source::SourceCache module, but does not implement the open_source method. Concrete subclasses of BaseSource must implement open_source.

Direct Known Subclasses

DSCSV, DSMetsXML, MarcXML, TeiXML

Instance Method Summary collapse

Methods included from SourceCache

#cache, #find_or_open_source, #max_cache_size, #max_cache_size=, #open_source

Instance Method Details

#load_source(source_path) ⇒ Object

Loads the specified source path.

Parameters:

  • source_path (String)

    The path to the source file.

Returns:

  • (Object)

    The parsed source file; e.g, Nokogiri::XML::Document or CSV::Table



23
24
25
# File 'lib/ds/source/base_source.rb', line 23

def load_source source_path
  find_or_open_source source_path
end

#source_typeObject



15
16
17
# File 'lib/ds/source/base_source.rb', line 15

def source_type
  self.class::TYPE
end

#to_sObject



27
28
29
# File 'lib/ds/source/base_source.rb', line 27

def to_s
  "#{self.class_name}: source_type #{source_type}"
end