First release of Qo, short for Query Object. It's my play at pattern
matching and fluent querying in Ruby based on a few of my posts earlier:
* Triple Equals Black Magic. For the most part, === is either… | by Brandon Weaver | Ruby Inside | Medium
* Having fun with M and Q · GitHub
···
*
Git Repo: GitHub - baweaver/qo: Qo - Query Object - Pattern matching and fluent querying in Ruby
A few quick examples:
case ['Robert', 22]
when Qo[:*, 10..19] then 'teenager'
when Qo[:*, 20..99] then 'adult'
else 'who knows'
end
people = [
['Robert', 22],
['Roberta', 22],
['Foo', 42],
['Bar', 18]
]
people.select(&Qo[:*, 15..25]) # => [["Robert", 22], ["Roberta", 22],
["Bar", 18]]
Enjoy!
- baweaver / lemur