Class: BooleanRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/rules/BooleanRule.rb

Instance Method Summary collapse

Constructor Details

#initializeBooleanRule

Returns a new instance of BooleanRule.



6
7
8
9
10
# File 'lib/rules/BooleanRule.rb', line 6

def initialize()

  @booleans = Set.new()

end

Instance Method Details

#resultObject



34
35
36
37
38
39
40
# File 'lib/rules/BooleanRule.rb', line 34

def result()
  {
    :type => :bool,
    :is_true => @booleans.include?,
    :is_false => @booleans.include?
  }
end

#test(value) ⇒ Object

Parameters:

  • value (Boolean)


28
29
30
31
32
# File 'lib/rules/BooleanRule.rb', line 28

def test(value)

  @booleans.include? value

end

#train(meta) ⇒ Object

Parameters:



15
16
17
18
19
20
21
22
23
# File 'lib/rules/BooleanRule.rb', line 15

def train(meta)

  value = meta[:value]

  unless value.nil?
    @booleans << value
  end

end