class Fire::State
Fire’s logic system is a *set logic* system. That means an empty set, ‘[]` is treated as `false` and a non-empty set is `true`.
Fire
handles complex logic by building-up lazy logic constructs. It’s logical operators are defined using single charcter symbols, e.g. ‘&` and `|`.
Public Class Methods
new(&procedure)
click to toggle source
# File lib/fire/state.rb, line 11 def initialize(&procedure) @procedure = procedure end
Public Instance Methods
&(other)
click to toggle source
set and
# File lib/fire/state.rb, line 25 def &(other) State.new{ set(self.call) & set(other.call) } end
call()
click to toggle source
# File lib/fire/state.rb, line 15 def call set @procedure.call end
|(other)
click to toggle source
set or
# File lib/fire/state.rb, line 20 def |(other) State.new{ set(self.call) | set(other.call) } end
Private Instance Methods
set(value)
click to toggle source
# File lib/fire/state.rb, line 32 def set(value) case value when Array value.compact when Boolean value ? true : [] else [value] end end