Sha256: debd46bed2f2d753213d6137e956af5b24ccd2ff443f7ec8e347a416bbd67414

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'berkeley_library/marc/field_info/var_fields/ind_val_def'
require 'berkeley_library/marc/field_info/var_fields/obsolescible'

module BerkeleyLibrary
  module Marc
    module FieldInfo
      module VarFields
        class IndDef
          # TODO: include Comparable
          include Obsolescible

          POS_NAMES = { 1 => 'First', 2 => 'Second' }.freeze

          attr_reader :pos
          attr_reader :desc
          attr_reader :val_defs

          def initialize(pos:, desc:, val_defs:)
            raise ArgumentError, "Not a valid indicator position: #{pos.inspect}" unless [1, 2].include?(pos)

            @pos = pos
            @desc = desc
            @val_defs = val_defs
          end

          def reject_obsoletes
            IndDef.new(pos: pos, desc: desc, val_defs: _reject_obsolete(val_defs))
          end

          def to_s
            lines = ["#{POS_NAMES[pos]} - #{desc}"]
            val_defs.each { |v| lines << "   #{v}" }
            lines.join("\n")
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
berkeley_library-marc-0.2.1 lib/berkeley_library/marc/field_info/var_fields/ind_def.rb
berkeley_library-marc-0.2.0 lib/berkeley_library/marc/field_info/var_fields/ind_def.rb