Class: CSVPlusPlus::Options
- Inherits:
-
Object
- Object
- CSVPlusPlus::Options
- Defined in:
- lib/csv_plus_plus/options.rb
Overview
The options a user can supply
Instance Attribute Summary collapse
-
#backup ⇒ Object
Returns the value of attribute backup.
-
#create_if_not_exists ⇒ Object
Returns the value of attribute create_if_not_exists.
-
#google ⇒ Object
readonly
Returns the value of attribute google.
-
#key_values ⇒ Object
Returns the value of attribute key_values.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#output_filename ⇒ Object
Returns the value of attribute output_filename.
-
#sheet_name ⇒ Object
Returns the value of attribute sheet_name.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#google_sheet_id=(sheet_id) ⇒ Object
Set the Google Sheet ID.
-
#initialize ⇒ Options
constructor
initialize.
-
#to_s ⇒ Object
to_s.
-
#validate ⇒ Object
Returns an error string or nil if there are no validation problems.
-
#verbose_summary ⇒ Object
Return a string with a verbose description of what we’re doing with the options.
Constructor Details
#initialize ⇒ Options
initialize
12 13 14 15 16 17 18 19 |
# File 'lib/csv_plus_plus/options.rb', line 12 def initialize @offset = [0, 0] @create_if_not_exists = false @key_values = {} @verbose = false # TODO: switch to true? probably a safer choice @backup = false end |
Instance Attribute Details
#backup ⇒ Object
Returns the value of attribute backup.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def backup @backup end |
#create_if_not_exists ⇒ Object
Returns the value of attribute create_if_not_exists.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def create_if_not_exists @create_if_not_exists end |
#google ⇒ Object (readonly)
Returns the value of attribute google.
9 10 11 |
# File 'lib/csv_plus_plus/options.rb', line 9 def google @google end |
#key_values ⇒ Object
Returns the value of attribute key_values.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def key_values @key_values end |
#offset ⇒ Object
Returns the value of attribute offset.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def offset @offset end |
#output_filename ⇒ Object
Returns the value of attribute output_filename.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def output_filename @output_filename end |
#sheet_name ⇒ Object
Returns the value of attribute sheet_name.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def sheet_name @sheet_name end |
#verbose ⇒ Object
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/csv_plus_plus/options.rb', line 8 def verbose @verbose end |
Instance Method Details
#google_sheet_id=(sheet_id) ⇒ Object
Set the Google Sheet ID
22 23 24 |
# File 'lib/csv_plus_plus/options.rb', line 22 def google_sheet_id=(sheet_id) @google = ::CSVPlusPlus::GoogleOptions.new(sheet_id) end |
#to_s ⇒ Object
to_s
59 60 61 62 |
# File 'lib/csv_plus_plus/options.rb', line 59 def to_s "Options(create_if_not_exists: #{@create_if_not_exists}, google: #{@google}, key_values: #{@key_values}, " \ "offset: #{@offset}, sheet_name: #{@sheet_name}, verbose: #{@verbose})" end |
#validate ⇒ Object
Returns an error string or nil if there are no validation problems
27 28 29 30 31 |
# File 'lib/csv_plus_plus/options.rb', line 27 def validate return if @google || @output_filename 'You must supply either a Google Sheet ID or an output file' end |
#verbose_summary ⇒ Object
Return a string with a verbose description of what we’re doing with the options
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/csv_plus_plus/options.rb', line 34 def verbose_summary " \#{summary_divider}\n\n # csv++ Command Options\n\n > Input filename | \#{@filename}\n > Sheet name | \#{@sheet_name}\n > Create sheet if it does not exist? | \#{@create_if_not_exists}\n > Spreadsheet row-offset | \#{@offset[0]}\n > Spreadsheet cell-offset | \#{@offset[1]}\n > User-supplied key-values | \#{@key_values}\n > Verbose | \#{@verbose}\n\n ## Output Options\n\n > Backup | \#{@backup}\n > Output filename | \#{@output_filename}\n\n \#{@google&.verbose_summary || ''}\n \#{summary_divider}\n SUMMARY\nend\n" |