Skip to content

Commit

Permalink
Merge pull request #8 from beatrizfagundes/change-blank-rails-method-…
Browse files Browse the repository at this point in the history
…to-nil-or-empty

Change blank? Rails method to nil? || strip.empty? Ruby-only approach
  • Loading branch information
beatrizfagundes authored May 23, 2018
2 parents 9b751f3 + a80ce52 commit f9b7c99
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ gem 'parsec'

* Use Ruby version 2.5.1

#### Add to the top of your <filename> file

```ruby
require 'parsec'
```

#### You can then eval equations in your code

```ruby
Expand All @@ -26,18 +20,6 @@ parser.eval_equation('5 + 1')
parser.eval_equation('(3 + 3) * (5 * 2)')
```

#### You can also validate the formula syntax

```ruby
parser = Parsec::Parsec
parser.validate_syntax('3>=2 ? 1 : 0') # correct syntax, returns true
```

```ruby
parser = Parsec::Parsec
parser.validate_syntax('3>=2 ? 1') # bad syntax, returns ArgumentError with appropriated message
```

#### Here are examples of equations which are accepted by the parser
```ruby
parser = Parsec::Parsec
Expand Down
2 changes: 1 addition & 1 deletion lib/string_to_boolean_refinements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module StringToBooleanRefinements
refine String do
def to_bool
return true if self == true || self =~ /(true|t|yes|y|1|on)$/i
return false if self == false || blank? || self =~ /(false|f|no|n|0|off)$/i
return false if self == false || nil? || strip.empty? || self =~ /(false|f|no|n|0|off)$/i
raise ArgumentError, "invalid value for Boolean: \"#{self}\""
end
end
Expand Down

0 comments on commit f9b7c99

Please sign in to comment.