Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
prodis committed Nov 5, 2017
1 parent 76339b5 commit 62298f2
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ $ gem install wannabe_bool

`to_b` method is available on `String`, `Symbol`, `Numeric`, `TrueClass`, `FalseClass` and `NilClass`.

For sake of readability (and personal choice), `to_b` has two aliases:
- `to_bool`
- `to_boolean`

Given this example:
```ruby
{
one: 'value',
two: 2,
mobile?: params[:mobile].to_b
}
```

It could be "more readable" like this:
```ruby
{
one: 'value',
two: 2,
mobile?: params[:mobile].to_boolean
}
```

Don't forget to require the gem:
```ruby
require 'wannabe_bool'
```
Expand Down Expand Up @@ -90,7 +113,7 @@ It ignores trailing spaces and letter cases.
''.to_b # => false
' '.to_b # => false
```
#### Invalid Value Behaviour
#### Invalid Value Behaviour for strings
You can configure the result for invalid boolean string representations, using the `WannabeBool.invalid_value_behaviour` option.

There are 3 predefined behaviours available: to return `false` (default), `nil` or raise an `ArgumentError`:
Expand Down

0 comments on commit 62298f2

Please sign in to comment.