class NoOp
def self.elif(cond)
NoOp
end
def self.else
NoOp
end
end
class Ifer
def initialize(cond)
@cond = cond
end
def then
if @cond
yield
NoOp
else
self
end
end
def elif(cond)
if cond
yield
NoOp
else
self
end
end
def else
if !@cond
yield
NoOp
else
self
end
end
end
def _if(cond)
Ifer.new cond
end
x = 4
_if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" }
x = 1
_if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" }
x = 0
_if(x > 3).then{ p "big" }.elif(x > 0){ p "medium"}.else{ p "small" }