Sha256: 0056a02c61c4e96f73e4ebf4e60dd5c7808226fefc2149037fcf388b4d026269
Contents?: true
Size: 838 Bytes
Versions: 2
Compression:
Stored size: 838 Bytes
Contents
require "iolite/lazy" require "iolite/functinal" module Iolite module Statement class IfThenElse def initialize cond, then_ @cond = cond @then_ = then_ end 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 end class If def initialize cond @cond = cond end 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 end def if_ cond If.new cond end module_function :if_ end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iolite-0.0.3 | lib/iolite/statement/if.rb |
iolite-0.0.2 | lib/iolite/statement/if.rb |