class LogicalLambda
Public Class Methods
define_comparable(compare_method)
click to toggle source
Comparables #############
# File lib/logical_lambda.rb, line 21 def self.define_comparable(compare_method) define_method compare_method do |other| if other.respond_to?(:call) LogicalLambda.new {|*args| call(*args).send(compare_method, other.call(*args)) } else # Must not be a block LogicalLambda.new {|*args| call(*args).send(compare_method, other) } end end end
Public Instance Methods
&(other)
click to toggle source
AND
# File lib/logical_lambda.rb, line 5 def &(other) LogicalLambda.new {|*args| call(*args) && other.call(*args) } end
|(other)
click to toggle source
OR
# File lib/logical_lambda.rb, line 15 def |(other) LogicalLambda.new {|*args| call(*args) || other.call(*args) } end