demarches-normaliennes/app/models/exported_column.rb

31 lines
618 B
Ruby

# frozen_string_literal: true
class ExportedColumn
attr_reader :column, :libelle
def initialize(column:, libelle:)
@column = column
@libelle = libelle
end
def id = { id: column.id, libelle: }.to_json
def libelle_with_value(champ_or_dossier, format:)
[libelle, ExportedColumnFormatter.format(column:, champ_or_dossier:, format:), spreadsheet_architect_type]
end
def spreadsheet_architect_type
case @column.type
when :boolean
:boolean
when :decimal, :integer
:float
when :datetime
:time
when :date
:date
else
:string
end
end
end