Class: DS::Extractor::Name

Inherits:
BaseTerm show all
Defined in:
lib/ds/extractor/name.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:, role: nil, vernacular: nil, ref: nil) ⇒ Object

Initializes a Name object with the provided parameters.

Parameters:

Parameters:

  • as_recorded (String)

    the recorded name

  • role (String, NilClass) (defaults to: nil)

    the role associated with the name

  • vernacular (String, NilClass) (defaults to: nil)

    the vernacular name

  • ref (String, NilClass) (defaults to: nil)

    the source authority URI



18
19
20
21
22
23
# File 'lib/ds/extractor/name.rb', line 18

def initialize as_recorded:, role: nil, vernacular: nil, ref: nil
  @role        = role
  @vernacular  = vernacular
  @ref         = ref
  super(as_recorded: as_recorded)
end

Instance Attribute Details

#refObject

Returns the value of attribute ref.



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

def ref
  @ref
end

#roleObject

Returns the value of attribute role.



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

def role
  @role
end

#vernacularObject

Returns the value of attribute vernacular.



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

def vernacular
  @vernacular
end

Instance Method Details

#to_aArray

Returns an array representation of the name.

[as_recorded, role, vernacular, ref]

Returns:

  • (Array)

    the name as an array



30
31
32
# File 'lib/ds/extractor/name.rb', line 30

def to_a
  [as_recorded, role, vernacular, ref]
end

#to_hHash

Returns a hash representation of the name object.

Keys are :as_recorded, :role, :name_agr, :source_authority_uri

Returns:

  • (Hash)

    the name as a hash



39
40
41
42
43
44
45
46
47
# File 'lib/ds/extractor/name.rb', line 39

def to_h
  {
    name_as_recorded: as_recorded,
    as_recorded: as_recorded,
    role: role,
    name_agr: vernacular,
    source_authority_uri: ref
  }
end