Class: Flist::Csvx

Inherits:
Object
  • Object
show all
Defined in:
lib/flist/csvx.rb

Overview

CSV操作用クラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fname) ⇒ Csvx

初期化



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/flist/csvx.rb', line 10

def initialize(fname)
  @headers_sym = %i[level kind repo path project comment atime ctime mtime]
  @headers_s = @headers_sym.map(&:to_s)

  @fname = fname
  @csv = if @fname
           CSV.open(@fname, 'w',
                    { encoding: 'UTF-8',
                      headers: @headers_s,
                      force_quotes: true,
                      write_headers: true })
         end
end

Instance Attribute Details

#csvObject

Returns the value of attribute csv.



7
8
9
# File 'lib/flist/csvx.rb', line 7

def csv
  @csv
end

#headers_sObject (readonly)

Returns the value of attribute headers_s.



6
7
8
# File 'lib/flist/csvx.rb', line 6

def headers_s
  @headers_s
end

Instance Method Details

#finishObject

終了処理



25
26
27
# File 'lib/flist/csvx.rb', line 25

def finish
  @csv&.close
end