Class: SpreadsheetBuilder::StringColumn
- Inherits:
-
Object
- Object
- SpreadsheetBuilder::StringColumn
- Defined in:
- backend/app/model/spreadsheet_builder.rb
Direct Known Subclasses
AccessionLookupColumn, BooleanColumn, DateStringColumn, EnumColumn, NoteContentColumn
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#index ⇒ Object
Returns the value of attribute index.
-
#jsonmodel ⇒ Object
Returns the value of attribute jsonmodel.
-
#locked ⇒ Object
Returns the value of attribute locked.
-
#name ⇒ Object
Returns the value of attribute name.
-
#property_name ⇒ Object
Returns the value of attribute property_name.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#header_label ⇒ Object
-
#initialize(jsonmodel, name, opts = {}) ⇒ StringColumn
constructor
A new instance of StringColumn.
-
#path ⇒ Object
-
#sanitise_incoming_value(value) ⇒ Object
-
#value_for(column_value) ⇒ Object
Constructor Details
#initialize(jsonmodel, name, opts = {}) ⇒ StringColumn
Returns a new instance of StringColumn.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'backend/app/model/spreadsheet_builder.rb', line 29 def initialize(jsonmodel, name, opts = {}) @jsonmodel = jsonmodel @name = name @header_label = opts.fetch(:header_label, nil) @column = opts.fetch(:column, name).intern @width = opts.fetch(:width, nil) @locked = opts.fetch(:locked, false) @property_name = opts.fetch(:property_name, jsonmodel).to_s @i18n = opts.fetch(:i18n, I18n.t("#{@jsonmodel}.#{@name}", :default => @name)) @i18n_proc = opts.fetch(:i18n_proc, nil) @path_proc = opts.fetch(:path_proc, nil) end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def column @column end |
#index ⇒ Object
Returns the value of attribute index
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def index @index end |
#jsonmodel ⇒ Object
Returns the value of attribute jsonmodel
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def jsonmodel @jsonmodel end |
#locked ⇒ Object
Returns the value of attribute locked
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def locked @locked end |
#name ⇒ Object
Returns the value of attribute name
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def name @name end |
#property_name ⇒ Object
Returns the value of attribute property_name
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def property_name @property_name end |
#width ⇒ Object
Returns the value of attribute width
27 28 29 |
# File 'backend/app/model/spreadsheet_builder.rb', line 27 def width @width end |
Instance Method Details
#header_label ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'backend/app/model/spreadsheet_builder.rb', line 46 def header_label if @header_label.nil? if @i18n_proc @index = 0 if @index.nil? @header_label = @i18n_proc.call(self) else if @index.nil? @header_label = @i18n else @header_label = "#{I18n.t("#{jsonmodel}._singular")} #{index + 1} - #{@i18n}" end end end @header_label end |
#path ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'backend/app/model/spreadsheet_builder.rb', line 62 def path if @path_proc return @path_proc.call(self) end if jsonmodel == :archival_object name.to_s else [@property_name, index, name].join('/') end end |
#sanitise_incoming_value(value) ⇒ Object
74 75 76 77 78 |
# File 'backend/app/model/spreadsheet_builder.rb', line 74 def sanitise_incoming_value(value) return nil if value.nil? value.to_s.strip end |
#value_for(column_value) ⇒ Object
42 43 44 |
# File 'backend/app/model/spreadsheet_builder.rb', line 42 def value_for(column_value) column_value end |