summaryrefslogtreecommitdiff
path: root/lib/csv/table.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 06:49:59 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 06:49:59 +0000
commit24b57b102c1992b679f8f8c0fd1a0239289a129b (patch)
treee25055dbfcef70d3b01855c004e57e130b3fac5f /lib/csv/table.rb
parentcdca14e75e98e2657daa40589f18a0ad46846020 (diff)
Upgrade CSV to 3.0.4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/csv/table.rb')
-rw-r--r--lib/csv/table.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/csv/table.rb b/lib/csv/table.rb
index b13d1ada10..71eb885de5 100644
--- a/lib/csv/table.rb
+++ b/lib/csv/table.rb
@@ -19,7 +19,7 @@ class CSV
# The optional +headers+ parameter can be set to Array of headers.
# If headers aren't set, headers are fetched from CSV::Row objects.
# Otherwise, headers() method will return headers being set in
- # headers arugument.
+ # headers argument.
#
# A CSV::Table object supports the following Array methods through
# delegation:
@@ -133,10 +133,15 @@ class CSV
#
# Returns the headers for the first row of this table (assumed to match all
- # other rows). An empty Array is returned for empty tables.
+ # other rows). The headers Array passed to CSV::Table.new is returned for
+ # empty tables.
#
def headers
- @headers.dup
+ if @table.empty?
+ @headers.dup
+ else
+ @table.first.headers
+ end
end
#