module Matchrb
Constants
- VERSION
Public Instance Methods
match(something, patterns)
click to toggle source
# File lib/matchrb.rb, line 6 def match(something, patterns) apply = lambda do |action, value| return action unless action.respond_to?(:to_proc) action = action.to_proc action.arity.zero? ? action[] : action[value] end patterns.each do |pattern, action| if (value = pattern === something) return apply[action, value] end end nil end
otherwise()
click to toggle source
# File lib/matchrb.rb, line 23 def otherwise Object end