Class: SpreadsheetBuilder::EnumMapper
- Inherits:
-
Object
- Object
- SpreadsheetBuilder::EnumMapper
- Defined in:
- backend/app/model/spreadsheet_builder.rb
Class Method Summary collapse
-
.enum_id_to_spreadsheet_value(enum_id, enum_name) ⇒ Object
-
.enum_to_spreadsheet_value(enum_value, enum_name) ⇒ Object
-
.spreadsheet_value_to_enum(spreadsheet_value) ⇒ Object
Class Method Details
.enum_id_to_spreadsheet_value(enum_id, enum_name) ⇒ Object
924 925 926 927 928 929 930 |
# File 'backend/app/model/spreadsheet_builder.rb', line 924 def self.enum_id_to_spreadsheet_value(enum_id, enum_name) return enum_id if enum_id.to_s.empty? enum_value = BackendEnumSource.value_for_id(enum_name, enum_id) EnumMapper.enum_to_spreadsheet_value(enum_value, enum_name) end |
.enum_to_spreadsheet_value(enum_value, enum_name) ⇒ Object
932 933 934 935 936 937 938 |
# File 'backend/app/model/spreadsheet_builder.rb', line 932 def self.enum_to_spreadsheet_value(enum_value, enum_name) return enum_value if enum_value.to_s.empty? enum_label = I18n.t("enumerations.#{enum_name}.#{enum_value}", :default => enum_value) "#{enum_label} [#{enum_value}]" end |
.spreadsheet_value_to_enum(spreadsheet_value) ⇒ Object
940 941 942 943 944 945 946 947 |
# File 'backend/app/model/spreadsheet_builder.rb', line 940 def self.spreadsheet_value_to_enum(spreadsheet_value) return spreadsheet_value if spreadsheet_value.to_s.empty? if spreadsheet_value.to_s =~ /\[(.*)\]$/ $1 elsif raise "Could not parse enumeration value from: #{spreadsheet_value}" end end |