lib/stanford-mods/searchworks.rb in stanford-mods-1.1.0 vs lib/stanford-mods/searchworks.rb in stanford-mods-1.1.1
- old
+ new
@@ -382,15 +382,15 @@
vals = self.term_values([:origin_info,:place,:placeTerm])
vals
end
# For the date display only, the first place to look is in the dates without encoding=marc array.
- # If no such dates, select the first date in the pub_dates array. Otherwise return nil
+ # If no such dates, select the first date in the dates_marc_encoding array. Otherwise return nil
# @return [String] value for the pub_date_display Solr field for this document or nil if none
def pub_date_display
return dates_no_marc_encoding.first unless dates_no_marc_encoding.empty?
- return pub_dates.first unless pub_dates.empty?
+ return dates_marc_encoding.first unless dates_marc_encoding.empty?
return nil
end
# For the date indexing, sorting and faceting, the first place to look is in the dates with encoding=marc array.
# If that doesn't exist, look in the dates without encoding=marc array. Otherwise return nil
@@ -785,22 +785,26 @@
return nil
end
# @return [Array<String>] dates from dateIssued and dateCreated tags from origin_info with encoding="marc"
def dates_marc_encoding
- split_date_encodings unless @dates_marc_encoding
- return @dates_marc_encoding
+ @dates_marc_encoding ||= begin
+ parse_dates_from_originInfo
+ @dates_marc_encoding
+ end
end
# @return [Array<String>] dates from dateIssued and dateCreated tags from origin_info with encoding not "marc"
def dates_no_marc_encoding
- split_date_encodings unless @dates_no_marc_encoding
- return @dates_no_marc_encoding
+ @dates_no_marc_encoding ||= begin
+ parse_dates_from_originInfo
+ @dates_no_marc_encoding
+ end
end
# Populate @dates_marc_encoding and @dates_no_marc_encoding from dateIssued and dateCreated tags from origin_info
# with and without encoding=marc
- def split_date_encodings
+ def parse_dates_from_originInfo
@dates_marc_encoding = []
@dates_no_marc_encoding = []
self.origin_info.dateIssued.each { |di|
if di.encoding == "marc"
@dates_marc_encoding << di.text