StringSatisfy
create a string pattern with &(represents AND) and |(represents OR), check whether it can be satisfied with given strings.
Installation
Add this line to your application's Gemfile:
gem 'string_satisfy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install string_satisfy
Usage
object = StringSatisfy.new '( (A | B) & (C | D) ) | ( (E | F) & (G | H) )'
object.satisfied_with? 'A', 'B'
=> false
object.satisfied_with? 'A', 'C'
=> true
object.satisfied_with? 'E', 'F'
=> false
object.satisfied_with? 'E', 'G'
=> true
object.satisfied_with? 'A', 'E'
=> false
object.satisfied_with? 'A', 'F', 'G'
=> true
Contributing
- Fork it ( https://github.com/waterflowseast/string_satisfy/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request