Sha256: 67d7337d35ee0e7a6b82475db6c3342317d7e5a037eba406e4e036133340cb8d

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

unless defined? JRUBY_VERSION
  raise "Only works under JRUBY"
end

begin
  include_class Java::org.marc4j.marc.impl.RecordImpl
rescue NameError  => e
  jardir = File.join(File.dirname(__FILE__), '..', 'jars')
  require "#{jardir}/marc4j.jar"
end

# Define a method that will take a string (filename), IO object, or StringIO object,
# and return an inputstream/outputstream

module IOConvert
  
  def byteinstream(fromwhere)
    stream = nil
    if fromwhere.is_a? Java::JavaIO::InputStream
      stream = fromwhere
    elsif fromwhere.is_a? String
      stream = java.io.FileInputStream.new(fromwhere.to_java_string)
    elsif fromwhere.respond_to? :to_inputstream
      stream = fromwhere.to_inputstream
    end
    return stream
  end
  
  def byteoutstream towhere
    stream = nil
    if towhere.is_a? Java::JavaIO::OutputStream
      stream = towhere
    elsif towhere.is_a? String
      stream = java.io.FileOutputStream.new(towhere.to_java_string)
    elsif towhere.respond_to? :to_outputstream
      stream = towhere.to_outputstream
    end
    return stream
  end
  
  
  module_function :byteinstream, :byteoutstream
  
end
  
  
  
  

require 'marc4j4r/record.rb'
require 'marc4j4r/controlfield.rb'
require 'marc4j4r/reader.rb'
require 'marc4j4r/datafield.rb'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marc4j4r-0.9.0 lib/marc4j4r.rb
marc4j4r-0.2.4 lib/marc4j4r.rb
marc4j4r-0.2.2 lib/marc4j4r.rb