Sha256: 1e3ff006c290eaf02bd42a868770bb0307a6ff6852ebc39a22179316e8bf1b80

Contents?: true

Size: 706 Bytes

Versions: 5

Compression:

Stored size: 706 Bytes

Contents

module MARC

    # A class for writing MARC records as MARC21.

    class Writer

        # the constructor which you must pass a file path
        # or an object that responds to a write message

        def initialize(file)
            if file.class == String
                @fh = File.new(file,"w")
            elsif file.respond_to?(file)
                @fh = file
            else
                throw "must pass in file name or handle"
            end
        end


        # write a record to the file or handle

        def write(record)
            @fh.write(record.to_marc)
        end


        # close underlying filehandle

        def close
            @fh.close
        end

    end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
marc-0.0.5 lib/marc/writer.rb
marc-0.0.6 lib/marc/writer.rb
marc-0.0.3 lib/marc/writer.rb
marc-0.0.2 lib/marc/writer.rb
marc-0.0.4 lib/marc/writer.rb