Class: BooleanRule
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#initialize ⇒ BooleanRule
constructor
A new instance of BooleanRule.
- #random ⇒ Object
- #result ⇒ Object
- #test(value) ⇒ Object
- #train(meta) ⇒ Object
Constructor Details
#initialize ⇒ BooleanRule
Returns a new instance of BooleanRule.
6 7 8 9 10 11 |
# File 'lib/rules/BooleanRule.rb', line 6 def initialize() @type = :bool @booleans = Set.new() end |
Instance Method Details
#random ⇒ Object
43 44 45 |
# File 'lib/rules/BooleanRule.rb', line 43 def random() @booleans.to_a.sample end |
#result ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rules/BooleanRule.rb', line 36 def result() { :type => @type, :booleans => @booleans } end |
#test(value) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rules/BooleanRule.rb', line 29 def test(value) # Booleans are stored as strings. @booleans.include? value.to_s end |
#train(meta) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rules/BooleanRule.rb', line 16 def train() value = [:value] unless value.nil? @booleans << value end end |