module CSVSjis

Constants

SJIS_NAME
VERSION

Public Class Methods

open(file, mode = 'w', options = {}) { |builder| ... } click to toggle source
# File lib/csv_sjis.rb, line 8
def open(file, mode = 'w', options = {})
  options = {
    encoding: SJIS_NAME,
    undef: :replace,
    invalid: :replace
  }.merge(options)

  file = File.open(file, mode, options)
  csv = CSV.new(file, encoding: options[:encoding])
  builder = Builder.new(csv, options[:encoding] == SJIS_NAME)

  yield(builder) if block_given?

  builder
end