Module: Recon::Type::ReconType::ClassMethods

Defined in:
lib/ds/recon/type/recon_type.rb

Instance Method Summary collapse

Instance Method Details

#as_recorded_columnSymbol

Returns the column in the recon CSV that holds the as-recorded value; e.g., :author_as_recorded

Returns:

  • (Symbol)

    the import CSV as recorded column



84
85
86
# File 'lib/ds/recon/type/recon_type.rb', line 84

def as_recorded_column
  self::AS_RECORDED_COLUMN
end

#balanced_columnsArray<Symbol>

Returns the balanced columns for the current object.

Balanced columns should have equal numbers of fields and subfields in each row; e.g., if fields are delimited by ‘|’ and subfields by ‘;’, then the following are balanced:

structured_value,authorized_label a|b;c,d|e;f 1|2|3,x|y|z r,s

Examples:

Recon::Type::Materials.balanced_columns #=> [:structured_value, :authorized_label]

Returns:

  • (Array<Symbol>)

    The balanced columns.



117
118
119
# File 'lib/ds/recon/type/recon_type.rb', line 117

def balanced_columns
  self::BALANCED_COLUMNS
end

#delimiter_mapHash<Symbol,String>

Returns the delimiter repalcement map: { ORIGINAL => REPLACEMENT}; e.g., { ‘|’ => ‘;’ }

Returns:

  • (Hash<Symbol,String>)

    the delimiter map



91
92
93
# File 'lib/ds/recon/type/recon_type.rb', line 91

def delimiter_map
  self::DELIMITER_MAP
end

#get_key_values(row) ⇒ Array<String>

Return the values of the key columns in the given row.

Parameters:

  • row (Hash<Symbol,String>)

    The row to extract values from.

Returns:

  • (Array<String>)

    The values of the key columns in the given row.



126
127
128
# File 'lib/ds/recon/type/recon_type.rb', line 126

def get_key_values row
  key_columns.map { |key| row[key] }
end

#key_columnsArray<Symbol>

Returns the columns used to make the lookup key for the data dictionary; e.g., [:genre_as_recorded, :vocabulary]

Returns:

  • (Array<Symbol>)

    the key columns



77
78
79
# File 'lib/ds/recon/type/recon_type.rb', line 77

def key_columns
  self::KEY_COLUMNS
end

#lookup_columnsArray<Symbol>

Returns lookups should pulls from the data dictionaries; e.g., [:authorized_label, :structured_value, :ds_qid]

Returns:

  • (Array<Symbol>)

    the lookup columns



70
71
72
# File 'lib/ds/recon/type/recon_type.rb', line 70

def lookup_columns
  self::LOOKUP_COLUMNS
end

#lookup_values(row) ⇒ Object



130
131
132
# File 'lib/ds/recon/type/recon_type.rb', line 130

def lookup_values row
  lookup_columns.map { |key| row[key] }
end

#method_nameArray<Symbol>

Returns the name of the DS::Extractor methods; e.g., [:extract_places]

Returns:

  • (Array<Symbol>)

    the method name



98
99
100
# File 'lib/ds/recon/type/recon_type.rb', line 98

def method_name
  self::METHOD_NAME
end

#recon_csv_headersArray<Symbol>

Returns the recon CSV headers; e.g., [:place_as_recorded, :authorized_label, :structured_value, :ds_qid]

Returns:

  • (Array<Symbol>)

    the recon CSV headers



63
64
65
# File 'lib/ds/recon/type/recon_type.rb', line 63

def recon_csv_headers
  self::RECON_CSV_HEADERS
end

#set_nameSymbol

Returns the set name of the recon set; e.g., :places

Used to find a recon type configuration by name; either the ReconType (like Recon::Type::Places) or the path to the recon data dictionary CSV in the ds-data git repo as defined in config/settings.yml:

ds:
  recon:
    ...
    sets:
      - name: :places
        repo_path: terms/reconciled/places.csv
        key_column: place_as_recorded
        ...

Returns:

  • (Symbol)

    the set name



56
57
58
# File 'lib/ds/recon/type/recon_type.rb', line 56

def set_name
  self::SET_NAME
end