end
def heading
- result = []
-
- if @title.nil?
- result.push("<i>(Unknown title)</i>")
- else
- result.push("<b>#{@title}</b>")
- end
- result.push("<i>by #{@author.reading_order}</i>") unless @author.nil?
-
- series_info = []
- series = @store.load_series(@series_id)
- series_info.push(series.descr.to_s) if series&.descr
- series_info.push(@volume.to_s) unless @volume.nil?
- result.push(series_info.join(" ")) unless series_info.empty?
-
- classification = nil
- classification = @store.load_classification(@classification_id) unless @classification_id.nil?
- unless classification.nil?
- result.push("Dewey: #{classification.ddc}") unless classification.ddc.nil?
- result.push("LCC: #{classification.lcc}") unless classification.lcc.nil?
- end
-
- result.join("<br/>")
+ [
+ heading_title,
+ @author.nil? ? nil : "<i>by #{@author.reading_order}</i>",
+ heading_series_info,
+ heading_classification,
+ ].compact.join("<br/>")
end
def inspect
private
+ def heading_classification
+ return if @classification_id.nil?
+
+ classification = @store.load_classification(@classification_id) unless @classification_id.nil?
+ return if classification.nil?
+
+ [
+ classification.ddc.nil? ? nil : "Dewey: #{classification.ddc}",
+ classification.lcc.nil? ? nil : "LCC: #{classification.lcc}",
+ ].compact.join(" ")
+ end
+
+ def heading_series_info
+ series = @store.load_series(@series_id)
+
+ [
+ series&.descr&.to_s,
+ @volume&.to_s,
+ ].compact.join(" ")
+ end
+
+ def heading_title
+ if @title.nil?
+ "<i>(Unknown title)</i>"
+ else
+ "<b>#{@title}</b>"
+ end
+ end
+
def upper?(character)
/[[:upper:]]/.match(character)
end