Class: Flare::Tools::Cli::Dump::CsvDumper
- Defined in:
- lib/flare/tools/cli/dump.rb
Instance Attribute Summary
Attributes inherited from Dumper
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filepath_or_writable) ⇒ CsvDumper
constructor
A new instance of CsvDumper.
- #write(data, key, flag, len, version, expire) ⇒ Object
Constructor Details
#initialize(filepath_or_writable) ⇒ CsvDumper
Returns a new instance of CsvDumper.
60 61 62 63 64 65 66 67 68 |
# File 'lib/flare/tools/cli/dump.rb', line 60 def initialize filepath_or_writable @output = if filepath_or_writable.kind_of?(String) open(filepath_or_writable, 'w') else filepath_or_writable end @output.puts "# key, flag, len, version, expire, data" @writer = CSV::Writer.generate(@output, ',') end |
Class Method Details
.myname ⇒ Object
57 58 59 |
# File 'lib/flare/tools/cli/dump.rb', line 57 def self.myname "csv" end |
Instance Method Details
#close ⇒ Object
72 73 74 |
# File 'lib/flare/tools/cli/dump.rb', line 72 def close @output.close unless @output == STDOUT || @output == STDERR end |
#write(data, key, flag, len, version, expire) ⇒ Object
69 70 71 |
# File 'lib/flare/tools/cli/dump.rb', line 69 def write data, key, flag, len, version, expire @writer << [key, flag, len, version, expire, data] end |