Class: DS::Extractor::Title

Inherits:
BaseTerm show all
Defined in:
lib/ds/extractor/title.rb

Instance Attribute Summary collapse

Attributes inherited from BaseTerm

#as_recorded

Instance Method Summary collapse

Methods inherited from BaseTerm

#==, #eql?, #hash

Constructor Details

#initialize(as_recorded:, vernacular: nil, uniform_title: nil, uniform_title_vernacular: nil) ⇒ Title

Initializes a new Title object.

Parameters:

  • as_recorded: the title as recorded
  • vernacular: the vernacular title (default is nil)
  • uniform_title: the uniform title (default is nil)
  • uniform_title_vernacular: the vernacular uniform title (default is nil)

Returns:

  • A new Title object


21
22
23
24
25
26
# File 'lib/ds/extractor/title.rb', line 21

def initialize as_recorded:, vernacular: nil, uniform_title: nil, uniform_title_vernacular: nil
  @vernacular               = vernacular
  @uniform_title            = uniform_title
  @uniform_title_vernacular = uniform_title_vernacular
  super(as_recorded: as_recorded)
end

Instance Attribute Details

#title_type ⇒ Object

Returns the value of attribute title_type.



7
8
9
# File 'lib/ds/extractor/title.rb', line 7

def title_type
  @title_type
end

#uniform_title ⇒ Object

Returns the value of attribute uniform_title.



8
9
10
# File 'lib/ds/extractor/title.rb', line 8

def uniform_title
  @uniform_title
end

#uniform_title_vernacular ⇒ Object

Returns the value of attribute uniform_title_vernacular.



9
10
11
# File 'lib/ds/extractor/title.rb', line 9

def uniform_title_vernacular
  @uniform_title_vernacular
end

#vernacular ⇒ Object

Returns the value of attribute vernacular.



6
7
8
# File 'lib/ds/extractor/title.rb', line 6

def vernacular
  @vernacular
end

Instance Method Details

#to_a ⇒ Array

Returns an array containing the title as recorded, vernacular title, uniform title, and vernacular uniform title.

Returns:

  • (Array) —

    the title as an array



31
32
33
34
# File 'lib/ds/extractor/title.rb', line 31

def to_a
  # title_type is not included
  [as_recorded, vernacular, uniform_title, uniform_title_vernacular]
end

#to_h ⇒ Hash

Returns a hash representation of the title object.

Keys are :as_recorded, :title_as_recorded_agr, :uniform_title_as_recorded, :uniform_title_as_recorded_agr

Returns:

  • (Hash) —

    the title as a hash



41
42
43
44
45
46
47
48
49
# File 'lib/ds/extractor/title.rb', line 41

def to_h
  {
    title_as_recorded: as_recorded,
    as_recorded: as_recorded,
    title_as_recorded_agr: vernacular,
    uniform_title_as_recorded: uniform_title,
    uniform_title_as_recorded_agr: uniform_title_vernacular
  }
end