Module: ASpaceExport::ExportModelHelpers

Included in:
ExportModel
Defined in:
backend/app/exporters/lib/export_helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) extract_date_string(date)



170
171
172
173
174
175
176
177
178
# File 'backend/app/exporters/lib/export_helpers.rb', line 170

def extract_date_string(date)
  if date['expression']
    date['expression']
  elsif date['end'].nil? || date['end'] == date['begin']
    date['begin']
  else
    "#{date['begin']} - #{date['end']}"
  end
end

- (Object) extract_note_content(note)



181
182
183
184
185
186
187
# File 'backend/app/exporters/lib/export_helpers.rb', line 181

def extract_note_content(note)
  if note['content']
    Array(note['content']).join(" ")
  else
    get_subnotes_by_type(note, 'note_text').map {|sn| sn['content']}.join(" ").gsub(/\n +/, "\n")
  end
end

- (Object) get_subnotes_by_type(obj, note_type)



190
191
192
# File 'backend/app/exporters/lib/export_helpers.rb', line 190

def get_subnotes_by_type(obj, note_type)
  obj['subnotes'].select {|sn| sn['jsonmodel_type'] == note_type}
end