Module: SortNameProcessor::CorporateEntity

Defined in:
backend/app/model/mixins/sort_name_processor.rb

Class Method Summary collapse

Class Method Details

.process(json, extras = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'backend/app/model/mixins/sort_name_processor.rb', line 69

def self.process(json, extras = {})
  result = ""

  result << "#{json["primary_name"]}" if json["primary_name"]
  result << ". #{json["subordinate_name_1"]}" if json["subordinate_name_1"]
  result << ". #{json["subordinate_name_2"]}" if json["subordinate_name_2"]

  grouped = [json["number"]].reject {|v| v.nil?}
  result << ", #{grouped.join(" : ")}" if not grouped.empty?
  result << " (#{json["qualifier"]})" if json["qualifier"]

  result << " (#{json["dates"]})" if json["dates"]
  result << " (#{json["location"]})" if json["location"]

  result.length > 255 ? result[0..254] : result
end