diff --git a/README.md b/README.md index 0707bed..49cabca 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,6 @@ gem 'parsec' * Use Ruby version 2.5.1 -#### Add to the top of your file - -```ruby -require 'parsec' -``` - #### You can then eval equations in your code ```ruby @@ -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 diff --git a/lib/string_to_boolean_refinements.rb b/lib/string_to_boolean_refinements.rb index 152ccdf..1a1062e 100644 --- a/lib/string_to_boolean_refinements.rb +++ b/lib/string_to_boolean_refinements.rb @@ -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