Class: CsvGenerator
- Inherits:
-
Object
- Object
- CsvGenerator
- Defined in:
- lib/csv_generator.rb,
lib/csv_generator/version.rb
Defined Under Namespace
Classes: RowGenerator
Constant Summary collapse
- VERSION =
'0.5.0'
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(row_values) ⇒ Object
-
#initialize(io) ⇒ CsvGenerator
constructor
A new instance of CsvGenerator.
Constructor Details
#initialize(io) ⇒ CsvGenerator
Returns a new instance of CsvGenerator.
24 25 26 |
# File 'lib/csv_generator.rb', line 24 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
4 5 6 |
# File 'lib/csv_generator.rb', line 4 def io @io end |
Class Method Details
.generate(path, options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/csv_generator.rb', line 7 def generate(path, = {}, &block) mode = [:mode] || 'w' = [:permission] || 0644 File.open(path, mode, ) do |io| with io, &block end end |
.with(io) {|generator| ... } ⇒ Object
16 17 18 19 20 21 |
# File 'lib/csv_generator.rb', line 16 def with(io) generator = new(io) yield generator if block_given? generator end |
Instance Method Details
#<<(row_values) ⇒ Object
28 29 30 |
# File 'lib/csv_generator.rb', line 28 def <<(row_values) io.write row_generator.generate(row_values) end |