summaryrefslogtreecommitdiff
path: root/lib/csv/writer.rb
diff options
context:
space:
mode:
authorSutou Kouhei <[email protected]>2019-10-12 14:03:21 +0900
committerGitHub <[email protected]>2019-10-12 14:03:21 +0900
commit92df7d98b62f48cf21cdec522f2e7b34380fd718 (patch)
treea0d169e177ebd5607caefa26cef90cc70df48232 /lib/csv/writer.rb
parentd6e68bb263e79cb802fa683d9c4139ddca2fd4f5 (diff)
Import CSV 3.1.2 (#2547)
Notes
Notes: Merged-By: kou <[email protected]>
Diffstat (limited to 'lib/csv/writer.rb')
-rw-r--r--lib/csv/writer.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/csv/writer.rb b/lib/csv/writer.rb
index 1682ac03ea..9243d23641 100644
--- a/lib/csv/writer.rb
+++ b/lib/csv/writer.rb
@@ -6,7 +6,12 @@ require_relative "row"
using CSV::MatchP if CSV.const_defined?(:MatchP)
class CSV
+ # Note: Don't use this class directly. This is an internal class.
class Writer
+ #
+ # A CSV::Writer receives an output, prepares the header, format and output.
+ # It allows us to write new rows in the object and rewind it.
+ #
attr_reader :lineno
attr_reader :headers
@@ -22,6 +27,9 @@ class CSV
@fields_converter = @options[:fields_converter]
end
+ #
+ # Adds a new row
+ #
def <<(row)
case row
when Row
@@ -47,6 +55,9 @@ class CSV
self
end
+ #
+ # Winds back to the beginning
+ #
def rewind
@lineno = 0
@headers = nil if @options[:headers].nil?