Class: Putcstst::CSVPrinter
- Inherits:
-
Object
- Object
- Putcstst::CSVPrinter
- Defined in:
- lib/putcstst.rb
Overview
class Error < StandardError; end
Instance Method Summary collapse
-
#initialize(filepath) ⇒ CSVPrinter
constructor
A new instance of CSVPrinter.
-
#print ⇒ Object
2D(2 column) Array Only.
Constructor Details
#initialize(filepath) ⇒ CSVPrinter
8 9 10 |
# File 'lib/putcstst.rb', line 8 def initialize(filepath) @file = filepath end |
Instance Method Details
#print ⇒ Object
2D(2 column) Array Only
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/putcstst.rb', line 12 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 |