Class: ApiMe::CsvStreamWriter
- Inherits:
-
Object
- Object
- ApiMe::CsvStreamWriter
- Defined in:
- lib/api_me/csv_stream_writer.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Class Method Summary collapse
-
.generate(stream) {|CsvStreamWriter| ... } ⇒ Object
Provides a similar interface to CSV.generate but compatible with an IO stream.
Instance Method Summary collapse
- #<<(row) ⇒ Object
-
#initialize(stream) ⇒ CsvStreamWriter
constructor
A new instance of CsvStreamWriter.
Constructor Details
#initialize(stream) ⇒ CsvStreamWriter
Returns a new instance of CsvStreamWriter.
23 24 25 |
# File 'lib/api_me/csv_stream_writer.rb', line 23 def initialize(stream) @stream = stream end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
8 9 10 |
# File 'lib/api_me/csv_stream_writer.rb', line 8 def stream @stream end |
Class Method Details
.generate(stream) {|CsvStreamWriter| ... } ⇒ Object
Provides a similar interface to CSV.generate but compatible with an IO stream
18 19 20 |
# File 'lib/api_me/csv_stream_writer.rb', line 18 def self.generate(stream) yield new(stream) end |
Instance Method Details
#<<(row) ⇒ Object
28 29 30 |
# File 'lib/api_me/csv_stream_writer.rb', line 28 def <<(row) stream.write CSV.generate_line(row) end |