summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-19 22:07:44 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-19 22:07:44 +0000
commit0503756fe5e56453ba1e10674615b71cd2c5a554 (patch)
tree6b33d0fe58906ae1142fc37954c9466ffb9f00b8
parentf205ac490e5b05e9c070a992ad6bb9cf5988104e (diff)
* lib/csv.rb (Object#CSV, Array#to_csv, String#parse_csv):
Examples and documentation for CSV. [Bug #6880] [ruby-core:47218] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/csv.rb31
2 files changed, 32 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ff46b2b8c9..deda156ebcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Sep 20 07:05:00 2012 Zachary Scott <zzak@ruby-lang.org>
+
+ * lib/csv.rb (Object#CSV, Array#to_csv, String#parse_csv):
+ Examples and documentation for CSV.
+ [Bug #6880] [ruby-core:47218]
+
Thu Sep 20 00:42:20 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (take_items), enum.c (enum_zip): raise TypeError at
diff --git a/lib/csv.rb b/lib/csv.rb
index bd83a6de68c..ede7c3b0d84 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -2359,20 +2359,41 @@ class CSV
end
end
-# Another name for CSV::instance().
+# Passes +args+ to CSV::instance.
+#
+# CSV("CSV,data").read
+# #=> [["CSV", "data"]]
+#
+# If a block is given, the instance is passed the block and the return value
+# becomes the return value of the block.
+#
+# CSV("CSV,data") { |c|
+# c.read.any? { |a| a.include?("data") }
+# } #=> true
+#
+# CSV("CSV,data") { |c|
+# c.read.any? { |a| a.include?("zombies") }
+# } #=> false
+#
def CSV(*args, &block)
CSV.instance(*args, &block)
end
-class Array
- # Equivalent to <tt>CSV::generate_line(self, options)</tt>.
+class Array # :nodoc:
+ # Equivalent to CSV::generate_line(self, options)
+ #
+ # ["CSV", "data"].to_csv
+ # #=> "CSV,data\n"
def to_csv(options = Hash.new)
CSV.generate_line(self, options)
end
end
-class String
- # Equivalent to <tt>CSV::parse_line(self, options)</tt>.
+class String # :nodoc:
+ # Equivalent to CSV::parse_line(self, options)
+ #
+ # "CSV,data".parse_csv
+ # #=> ["CSV", "data"]
def parse_csv(options = Hash.new)
CSV.parse_line(self, options)
end