Class: Tracksperanto::FormatDetector

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(with_path) ⇒ FormatDetector

Returns a new instance of FormatDetector.



6
7
8
9
# File 'lib/tracksperanto/format_detector.rb', line 6

def initialize(with_path)
  perform_detection(with_path)
  freeze
end

Instance Method Details

#auto_size?Boolean

Tells if comp size needs to be provided

Returns:

  • (Boolean)


22
23
24
# File 'lib/tracksperanto/format_detector.rb', line 22

def auto_size?
  match? ? importer_klass.autodetects_size? : false
end

#human_importer_nameObject

Returns the human name of the importer



27
28
29
# File 'lib/tracksperanto/format_detector.rb', line 27

def human_importer_name
  match? ? importer_klass.human_name : "Unknown format"
end

#importer_klassObject

Returns the importer if there is one



17
18
19
# File 'lib/tracksperanto/format_detector.rb', line 17

def importer_klass
  @importer_klass
end

#match?Boolean

Tells if an importer has been found for this file

Returns:

  • (Boolean)


12
13
14
# File 'lib/tracksperanto/format_detector.rb', line 12

def match?
  !!@importer_klass
end