Sha256: a113377b0c323eb818a213d70efe43fcf97bdceaf8d0569cd598dbaea6f7d12f

Contents?: true

Size: 500 Bytes

Versions: 2

Compression:

Stored size: 500 Bytes

Contents

module GogoCsv
  class ::Array
    def save!(path='./output.csv')
      raise 'should be array of array' unless arys?
      raise 'Should supply file path' unless path ||= $current_path

      CSV.open(File.expand_path(path), "wb") do |csv|
        each { |ary| csv <<  ary }
      end
    end

    def map_col!(from_num, to_num=from_num, &blk)
      each { |row| row[to_num] = blk.(row[from_num]) }
    end

    private

      def arys?
        all? { |item| item.is_a?(Array) }
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gogo_csv-0.0.7 lib/gogo_csv/array.rb
gogo_csv-0.0.6 lib/gogo_csv/array.rb