class CSVSjis::Builder
Public Instance Methods
<<(row)
click to toggle source
# File lib/csv_sjis.rb, line 26 def <<(row) csv << row.map{ |col| col.is_a?(String) && is_sjis ? sjis_safe(col) : col } end
Also aliased as: push
method_missing(method, *args, &block)
click to toggle source
# File lib/csv_sjis.rb, line 50 def method_missing(method, *args, &block) csv.send(method, *args, &block) end
sjis_safe(str)
click to toggle source
# File lib/csv_sjis.rb, line 34 def sjis_safe(str) [ ["FF5E", "007E"], # wave-dash ["FF0D", "002D"], # full-width minus ["00A2", "FFE0"], # cent as currency ["00A3", "FFE1"], # lb(pound) as currency ["00AC", "FFE2"], # not in boolean algebra ["2014", "2015"], # hyphen ["2016", "2225"], # double vertical lines ].inject(str) do |s, (before, after)| s.gsub( before.to_i(16).chr('UTF-8'), after.to_i(16).chr('UTF-8')) end end