Class: CSVPlusPlus::Options::FileOptions
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/csv_plus_plus/options/file_options.rb
Overview
The options that are specific for compiling to a file
Instance Attribute Summary collapse
-
#output_filename ⇒ Pathname
The file to write our compiled results to.
Attributes inherited from Options
#backup, #create_if_not_exists, #key_values, #offset, #overwrite_values, #sheet_name, #verbose
Instance Method Summary collapse
-
#initialize(sheet_name, output_filename) ⇒ FileOptions
constructor
Initialize an
Options
object for writing to a file. -
#output_format ⇒ Options::OutputFormat
Given the options, figure out which type of
OutputFormat
we’ll be writing to. -
#verbose_summary ⇒ String
Verbose summary for options specific to compiling to a file.
Constructor Details
#initialize(sheet_name, output_filename) ⇒ FileOptions
Initialize an Options
object for writing to a file
18 19 20 21 22 |
# File 'lib/csv_plus_plus/options/file_options.rb', line 18 def initialize(sheet_name, output_filename) super(sheet_name) @output_filename = ::T.let(::Pathname.new(output_filename), ::Pathname) end |
Instance Attribute Details
#output_filename ⇒ Pathname
The file to write our compiled results to
9 10 11 |
# File 'lib/csv_plus_plus/options/file_options.rb', line 9 def output_filename @output_filename end |
Instance Method Details
#output_format ⇒ Options::OutputFormat
Given the options, figure out which type of OutputFormat
we’ll be writing to
28 29 30 31 32 33 34 35 |
# File 'lib/csv_plus_plus/options/file_options.rb', line 28 def output_format case output_filename.extname when '.csv' then ::CSVPlusPlus::Options::OutputFormat::CSV when '.ods' then ::CSVPlusPlus::Options::OutputFormat::OpenDocument when /\.xl(sx|sm|tx|tm)$/ then ::CSVPlusPlus::Options::OutputFormat::Excel else raise(::CSVPlusPlus::Error::CLIError, "Unsupported file extension: #{output_filename}") end end |
#verbose_summary ⇒ String
Verbose summary for options specific to compiling to a file
41 42 43 44 45 46 |
# File 'lib/csv_plus_plus/options/file_options.rb', line 41 def verbose_summary shared_summary( <<~OUTPUT) > Output filename | #{output_filename} OUTPUT end |