Class: Bricolage::SpreadsheetDataSource::RowFormatterFactory::JSONFormatter
- Inherits:
-
Object
- Object
- Bricolage::SpreadsheetDataSource::RowFormatterFactory::JSONFormatter
- Defined in:
- lib/bricolage/spreadsheetdatasource.rb
Instance Method Summary collapse
Instance Method Details
#format(values, fields) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 162 def format(values, fields) # https://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby normalized_fields = fields.map {|f| f.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). tr(" ", "_"). downcase } normalized_fields.zip(values).to_h.to_json end |
#skip_header? ⇒ Boolean
175 176 177 |
# File 'lib/bricolage/spreadsheetdatasource.rb', line 175 def skip_header? true end |