Sha256: da0b263124dd69b99fb04cc953e4f4d6c6679f7c1620095c8a6863be43fb3bab

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

require "putcstst/version"
require "csv"

module Putcstst
  # class Error < StandardError; end

  class CSVPrinter
    def initialize(filepath)
      @file = filepath
    end

    def print # 2D(2 column) Array Only
      CSV.foreach(@file) do |data|
        format = data.each_with_object("") do |_, str|
          str << "%10s"
          # str += "%10s" ## これはだめ。ふしぎ!
          # yieldの返り値が結合後にならないからなのかと思ったが
          # returnはちゃんと返されてる 
        end

        puts sprintf(format, *data)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
putcstst-0.1.0 lib/putcstst.rb