README.md in recite_csv-0.1.1 vs README.md in recite_csv-0.1.2

- old
+ new

@@ -2,10 +2,11 @@ ReciteCSV helps to build a class for CSV reader. [![Gem Version](https://badge.fury.io/rb/recite_csv.svg)](https://badge.fury.io/rb/recite_csv) [![Build Status](https://travis-ci.org/yujideveloper/recite_csv.svg?branch=master)](https://travis-ci.org/yujideveloper/recite_csv) +[![Maintainability](https://api.codeclimate.com/v1/badges/eb04cab6d55b0c7a1f7f/maintainability)](https://codeclimate.com/github/yujideveloper/recite_csv/maintainability) ## Installation Add this line to your application's Gemfile: @@ -86,11 +87,11 @@ ``` Define custom methods of row object using `row_methods`. ``` ruby -class Quz +class Qux include ReciteCSV::Reader::Builder.new(col1: "COL1", col2: "COL2") row_methods do def col1 "override #{super}" @@ -100,16 +101,41 @@ # do somethings.. end end end -Quz.new("./example.csv").each do |row| - row.class # => Quz::Row +Qux.new("./example.csv").each do |row| + row.class # => Qux::Row row.col1 row.col2 row.custom_method end ``` + +Specify file mode and encoding. + +``` ruby +class Quux + include ReciteCSV::Reader::Builder.new(col1: "COL1", col2: "COL2") +end + +Quux.new("./example.csv", file_options: "rb:UTF-8").each do |row| + # do something +end +``` + +Convert encoding. + +``` ruby +class Corge + include ReciteCSV::Reader::Builder.new(col1: "COL1", col2: "COL2") +end + +Corge.new("./example.csv", file_options: ["rb:Shift_JIS:UTF-8", invalid: :replace, undef: :replace]).each do |row| + # do something +end +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.