Class: InlineDataHelper
- Inherits:
-
Object
- Object
- InlineDataHelper
- Defined in:
- app/aides/inline_data_helper.rb
Constant Summary collapse
- JOINER =
', '
- SPLITTER =
/[,\n] */
- CSV_OPTIONS =
{ col_sep: ', ', quote_char: '"' }
Class Method Summary collapse
Class Method Details
.generate_inline_values(values) ⇒ Object
39 40 41 |
# File 'app/aides/inline_data_helper.rb', line 39 def self.generate_inline_values(values) values.to_csv(**CSV_OPTIONS).strip end |
.parse_inline_values(inline_values) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/aides/inline_data_helper.rb', line 28 def self.parse_inline_values(inline_values) = CSV_OPTIONS.clone [:col_sep] = [:col_sep].strip begin values = inline_values.parse_csv(**) rescue CSV::MalformedCSVError => exc values = inline_values.parse_csv(**CSV_OPTIONS) end values ? values.compact.map(&:strip) : [] end |