Sha256: 82519360adf4f95cd9d6dfadafe0d9003234fbf59b21a170746611192ec78fc0
Contents?: true
Size: 780 Bytes
Versions: 14
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true require 'arclight/exceptions' module Arclight ## # A utility class to normalize titles, typically by joining # the title and date, e.g., "My Title, 1990-2000" class NormalizedTitle # @param [String] `title` from the `unittitle` # @param [String] `date` from the `unitdate` def initialize(title, date = nil) @title = title.gsub(/\s*,\s*$/, '').strip if title.present? @date = date.strip if date.present? end # @return [String] the normalized title/date def to_s normalize end private attr_reader :title, :date, :default def normalize result = [title, date].compact.join(', ') raise Arclight::Exceptions::TitleNotFound if result.blank? result end end end
Version data entries
14 entries across 14 versions & 1 rubygems