class Object
allow to convert any object to matcher if it has === method
Constants
- BinaryTree
Product can have its fields named.
- Color
Matchers also support logical operations #& for and, #| for or, and #! for negation.
- Contact
- Finished
- Maybe
Let's define some types
- Menu
Whenever you find yourself to pass around too many fragile Hash-Array structures e.g. for menus.
- Message
- Quarter
- Request
Lets define message-protocol for a cross-process communication.
- Response
- Season
It also works as expected when modules like Comparable are included.
- Tree
Simple data structures like trees
- Work
Public Instance Methods
color?(color)
click to toggle source
# File doc/pattern_matching.in.rb, line 86 def color?(color) match color, on(Black | Grey.(-> v { v < 0.2 }), 'black-ish'), on(White | Grey.(-> v { v > 0.8 }), 'white-ish'), on(Grey.(-> v { v >= 0.2 }) & Grey.(-> v { v <= 0.8 }), 'grey-ish'), on(Pink, "that's not a color ;)") end
deliver_email(email)
click to toggle source
# File doc/null.in.rb, line 3 def deliver_email(email) true end
to_m()
click to toggle source
# File lib/algebrick/matchers/wrapper.rb, line 52 def to_m Wrapper.new(self) end