diff options
Diffstat (limited to 'lib/csv/core_ext')
-rw-r--r-- | lib/csv/core_ext/array.rb | 9 | ||||
-rw-r--r-- | lib/csv/core_ext/string.rb | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/csv/core_ext/array.rb b/lib/csv/core_ext/array.rb new file mode 100644 index 0000000000..94df7d5c35 --- /dev/null +++ b/lib/csv/core_ext/array.rb @@ -0,0 +1,9 @@ +class Array # :nodoc: + # Equivalent to CSV::generate_line(self, options) + # + # ["CSV", "data"].to_csv + # #=> "CSV,data\n" + def to_csv(**options) + CSV.generate_line(self, options) + end +end diff --git a/lib/csv/core_ext/string.rb b/lib/csv/core_ext/string.rb new file mode 100644 index 0000000000..8f2070f3bd --- /dev/null +++ b/lib/csv/core_ext/string.rb @@ -0,0 +1,9 @@ +class String # :nodoc: + # Equivalent to CSV::parse_line(self, options) + # + # "CSV,data".parse_csv + # #=> ["CSV", "data"] + def parse_csv(**options) + CSV.parse_line(self, options) + end +end |