Class: Pandocomatic::MultipleFilesInput
- Defined in:
- lib/pandocomatic/multiple_files_input.rb
Overview
A specific Input class to handle multiple input files
Instance Attribute Summary
Attributes inherited from Input
Instance Method Summary collapse
-
#destroy! ⇒ Object
Destroy the temporary file created for this MultipleFilesInput.
-
#directory? ⇒ Boolean
Is this input a directory? A MultipleFilesInput cannot be a directory.
-
#initialize(input, config) ⇒ MultipleFilesInput
constructor
Create a new MultipleFilesInput.
-
#name ⇒ Object
The name of this input.
-
#to_s ⇒ Object
A string representation of this Input.
Methods inherited from Input
#absolute_path, #base, #errors?
Constructor Details
#initialize(input, config) ⇒ MultipleFilesInput
Create a new MultipleFilesInput. As a side-effect a temporary file is created as well containing the content of all the files in input.
31 32 33 34 35 |
# File 'lib/pandocomatic/multiple_files_input.rb', line 31 def initialize(input, config) super(input) @config = config create_temp_file end |
Instance Method Details
#destroy! ⇒ Object
Destroy the temporary file created for this MultipleFilesInput
53 54 55 56 57 58 |
# File 'lib/pandocomatic/multiple_files_input.rb', line 53 def destroy! return if @tmp_file.nil? @tmp_file.close @tmp_file.unlink end |
#directory? ⇒ Boolean
Is this input a directory? A MultipleFilesInput cannot be a directory
48 49 50 |
# File 'lib/pandocomatic/multiple_files_input.rb', line 48 def directory? false end |
#name ⇒ Object
The name of this input
40 41 42 |
# File 'lib/pandocomatic/multiple_files_input.rb', line 40 def name @tmp_file.path end |
#to_s ⇒ Object
A string representation of this Input
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pandocomatic/multiple_files_input.rb', line 63 def to_s input_string = @input_files.first previous_dir = File.dirname @input_files.first @input_files.slice(1..-1).each do |f| current_dir = File.dirname f if current_dir == previous_dir input_string += " + #{File.basename f}" else previous_dir = current_dir input_string += " + #{f}" end end input_string end |