diff options
Diffstat (limited to 'lib/csv.rb')
-rw-r--r-- | lib/csv.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 4893b94e88..61702137d0 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -432,7 +432,7 @@ class CSV # fetch or create the instance for this signature @@instances ||= Hash.new - instance = (@@instances[sig] ||= new(data, options)) + instance = (@@instances[sig] ||= new(data, **options)) if block_given? yield instance # run block, if given, returning result @@ -480,8 +480,8 @@ class CSV end end # build input and output wrappers - input = new(input || ARGF, in_options) - output = new(output || $stdout, out_options) + input = new(input || ARGF, **in_options) + output = new(output || $stdout, **out_options) # read, yield, write input.each do |row| @@ -505,8 +505,8 @@ class CSV # but transcode it to UTF-8 before CSV parses it. # def self.foreach(path, mode="r", **options, &block) - return to_enum(__method__, path, mode, options) unless block_given? - open(path, mode, options) do |csv| + return to_enum(__method__, path, mode, **options) unless block_given? + open(path, mode, **options) do |csv| csv.each(&block) end end @@ -539,7 +539,7 @@ class CSV str = +"" str.force_encoding(encoding) if encoding end - csv = new(str, options) # wrap + csv = new(str, **options) # wrap yield csv # yield for appending csv.string # return final String end @@ -565,7 +565,7 @@ class CSV elsif field = row.find {|f| f.is_a?(String)} str.force_encoding(field.encoding) end - (new(str, options) << row).string + (new(str, **options) << row).string end # @@ -645,7 +645,7 @@ class CSV retry end begin - csv = new(f, options) + csv = new(f, **options) rescue Exception f.close raise @@ -675,8 +675,8 @@ class CSV # You pass your +str+ to read from, and an optional +options+ containing # anything CSV::new() understands. # - def self.parse(*args, &block) - csv = new(*args) + def self.parse(*args, **options, &block) + csv = new(*args, **options) return csv.each(&block) if block_given? @@ -696,7 +696,7 @@ class CSV # The +options+ parameter can be anything CSV::new() understands. # def self.parse_line(line, **options) - new(line, options).shift + new(line, **options).shift end # @@ -710,13 +710,13 @@ class CSV # <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file # but transcode it to UTF-8 before CSV parses it. # - def self.read(path, *options) - open(path, *options) { |csv| csv.read } + def self.read(*args, **options) + open(*args, **options) { |csv| csv.read } end # Alias for CSV::read(). - def self.readlines(*args) - read(*args) + def self.readlines(*args, **options) + read(*args, **options) end # @@ -727,9 +727,9 @@ class CSV # header_converters: :symbol }.merge(options) ) # def self.table(path, **options) - read( path, { headers: true, - converters: :numeric, - header_converters: :symbol }.merge(options) ) + read( path, **{ headers: true, + converters: :numeric, + header_converters: :symbol }.merge(options) ) end # |