Class: Arclight::NormalizedTitle

Inherits:
Object
  • Object
show all
Defined in:
lib/arclight/normalized_title.rb

Overview

A utility class to normalize titles, typically by joining the title and date, e.g., “My Title, 1990-2000”

Instance Method Summary collapse

Constructor Details

#initialize(title, date = nil) ⇒ NormalizedTitle

Returns a new instance of NormalizedTitle.

Parameters:

  • `title` (String)

    from the ‘unittitle`

  • `date` (String)

    from the ‘unitdate`



12
13
14
15
# File 'lib/arclight/normalized_title.rb', line 12

def initialize(title, date = nil)
  @title = title.gsub(/\s*,\s*$/, '').strip if title.present?
  @date = date.strip if date.present?
end

Instance Method Details

#to_sString

Returns the normalized title/date.

Returns:

  • (String)

    the normalized title/date



18
19
20
# File 'lib/arclight/normalized_title.rb', line 18

def to_s
  normalize
end