Class: Traject::UMichFormat::XV6XX

Inherits:
Object
  • Object
show all
Defined in:
lib/traject/umich_format/xv6xx.rb

Overview

A utility class to get all the 6XX $v and $x, which are used over and over again in the format finder

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ XV6XX

Find all the 6XXxv values in the given record

Parameters:

  • record (MARC::Record)

7
8
9
10
11
12
13
14
# File 'lib/traject/umich_format/xv6xx.rb', line 7

def initialize(record)
  @vals = []
  record.fields('600'..'699').each do |f|
    f.each do |sf|
      @vals << sf.value if %[x v].include?(sf.code)
    end
  end
end

Instance Method Details

#match?(regex) ⇒ Boolean

Do any of the 6XXxv values match the given regex?

Parameters:

  • regex (Regexp)

    The regex to match

Returns:

  • (Boolean)

    Does the given regexp match at least one value?


20
21
22
# File 'lib/traject/umich_format/xv6xx.rb', line 20

def match?(regex)
  return @vals.grep(regex).size > 0
end