Class: Tracksperanto::FormatDetector
- Inherits:
-
Object
- Object
- Tracksperanto::FormatDetector
- Defined in:
- lib/tracksperanto/format_detector.rb
Overview
Finds a suitable importer for the chosen file path. Or at least tries to, based on the file extension. Will then examine all the importers and ask them if they can handle the specified file
Instance Method Summary collapse
-
#auto_size? ⇒ Boolean
Tells if comp size needs to be provided.
-
#human_importer_name ⇒ Object
Returns the human name of the importer.
-
#importer_klass ⇒ Object
Returns the importer if there is one.
-
#initialize(with_path) ⇒ FormatDetector
constructor
A new instance of FormatDetector.
-
#match? ⇒ Boolean
Tells if an importer has been found for this file.
Constructor Details
#initialize(with_path) ⇒ FormatDetector
Returns a new instance of FormatDetector.
5 6 7 8 |
# File 'lib/tracksperanto/format_detector.rb', line 5 def initialize(with_path) perform_detection(with_path) freeze end |
Instance Method Details
#auto_size? ⇒ Boolean
Tells if comp size needs to be provided
21 22 23 |
# File 'lib/tracksperanto/format_detector.rb', line 21 def auto_size? match? ? importer_klass.autodetects_size? : false end |
#human_importer_name ⇒ Object
Returns the human name of the importer
26 27 28 |
# File 'lib/tracksperanto/format_detector.rb', line 26 def human_importer_name match? ? importer_klass.human_name : "Unknown format" end |
#importer_klass ⇒ Object
Returns the importer if there is one
16 17 18 |
# File 'lib/tracksperanto/format_detector.rb', line 16 def importer_klass @importer_klass end |
#match? ⇒ Boolean
Tells if an importer has been found for this file
11 12 13 |
# File 'lib/tracksperanto/format_detector.rb', line 11 def match? !!@importer_klass end |