Class: OutputMode::Outputs::Delimited
- Inherits:
-
OutputMode::Output
- Object
- OutputMode::Output
- OutputMode::Outputs::Delimited
- Defined in:
- lib/output_mode/outputs/delimited.rb
Instance Attribute Summary
Attributes inherited from OutputMode::Output
#context, #default, #no, #procs, #yes
Instance Method Summary collapse
-
#config ⇒ Hash
Additional options to CSV.new.
-
#render(*data) ⇒ Object
Implements the render method using
CSV
.
Methods inherited from OutputMode::Output
#callables, #generate, #initialize
Constructor Details
This class inherits a constructor from OutputMode::Output
Instance Method Details
#config ⇒ Hash
Returns additional options to CSV.new.
34 |
# File 'lib/output_mode/outputs/delimited.rb', line 34 def config; super; end |
#render(*data) ⇒ Object
Implements the render method using CSV
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/output_mode/outputs/delimited.rb', line 40 def render(*data) io = StringIO.new csv = CSV.new(io, **config) data.each do |datum| csv << generate(datum).map do |value| next nil if value.nil? value.to_s.dump[1...-1] end end io.tap(&:rewind).read end |