README.md in mascherari-0.0.1 vs README.md in mascherari-0.0.2
- old
+ new
@@ -1,7 +1,8 @@
# Mascherari
+[![Gem Version](https://badge.fury.io/rb/mascherari.png)](https://badge.fury.io/rb/mascherari)
[![Build Status](https://travis-ci.org/robsonmarques/mascherari.png)](https://travis-ci.org/robsonmarques/mascherari)
[![Code Climate](https://codeclimate.com/github/robsonmarques/mascherari.png)](https://codeclimate.com/github/robsonmarques/mascherari)
An easy way to handle masks. (Work in progress)
@@ -17,31 +18,43 @@
```ruby
class Person
include Mascherari
- attr_accessor :phone, :mobile
+ attr_accessor :phone
- attr_masked :phone, :mobile, :format => "(##) ####-####"
+ attr_masked :phone, :format => "(##) ####-####"
end
```
-That will give you two helpers for each attribute:
+That will give you two helpers to use along with the object:
```ruby
# person.phone = "5554212035"
-# person.mobile = "5599213035"
person.phone_masked
=> "(55) 5421-2035"
-person.mobile_masked
-=> "(55) 9921-3035"
# person.phone = "(55) 5421-2035"
-# person.mobile = "(55) 9921-3035"
person.phone_unmasked
=> "5554212035"
-person.mobile_unmasked
-=> "5599213035"
+```
+
+You can set a format for more than one attribute:
+
+```ruby
+attr_masked :phone, :mobile, :format => "(##) ####-####"
+```
+
+And also use a different wildcard, if needed:
+
+```ruby
+attr_masked :phone, :format => "(**) ****-****", :wildcard => "*"
+```
+
+For the cases when format can vary, it's possible to set multiple formats:
+
+```ruby
+attr_masked :phone, :format => ["(##) ####-####", "(###) ####-####"]
```
## Rails
Add this line to your application's Gemfile: