class Iolite::Statement::If

Public Class Methods

new(cond) click to toggle source
# File lib/iolite/statement/if.rb, line 24
def initialize cond
        @cond = cond
end

Public Instance Methods

[](*then_) click to toggle source
# File lib/iolite/statement/if.rb, line 28
def [](*then_)
        if_then = Iolite::Lazy.new { |*args|
                if Iolite::Functinal.invoke(@cond, *args)
                        Iolite::Functinal.invoke_a(then_, *args).last
                end
        }
        cond = @cond
        (class << if_then; self; end).class_eval {
                define_method(:else_) {
                        IfThenElse.new cond, then_
                }
        }
        if_then
end