Class: Iolite::Statement::IfThenElse

Inherits:
Object
  • Object
show all
Defined in:
lib/iolite/statement/if.rb

Instance Method Summary collapse

Constructor Details

#initialize(cond, then_) ⇒ IfThenElse



7
8
9
10
# File 'lib/iolite/statement/if.rb', line 7

def initialize cond, then_
  @cond = cond
  @then_ = then_
end

Instance Method Details

#[](*else_) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/iolite/statement/if.rb', line 12

def [](*else_)
  Iolite.lazy { |*args|
    if Iolite::Functinal.invoke(@cond, *args)
      Iolite::Functinal.invoke_a(@then_, *args).last
    else
      Iolite::Functinal.invoke_a(else_, *args).last
    end
  }
end