Module: ASpaceExport::ExportModelHelpers

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

Instance Method Summary collapse

Instance Method Details

#extract_date_string(date) ⇒ Object



196
197
198
199
200
201
202
203
204
# File 'backend/app/exporters/lib/export_helpers.rb', line 196

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

#extract_note_content(note) ⇒ Object



207
208
209
210
211
212
213
# File 'backend/app/exporters/lib/export_helpers.rb', line 207

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

#get_subnotes_by_type(obj, note_type) ⇒ Object



216
217
218
# File 'backend/app/exporters/lib/export_helpers.rb', line 216

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