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`



10
11
12
13
# File 'lib/arclight/normalized_title.rb', line 10

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



16
17
18
# File 'lib/arclight/normalized_title.rb', line 16

def to_s
  normalize
end