Class: Reflekt::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.
7 8 9 10 |
# File 'lib/rules/boolean_rule.rb', line 7 def initialize() @type = :bool @booleans = Set.new() end |
Instance Method Details
#random ⇒ Object
38 39 40 |
# File 'lib/rules/boolean_rule.rb', line 38 def random() @booleans.to_a.sample end |
#result ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rules/boolean_rule.rb', line 31 def result() { :type => @type, :booleans => @booleans } end |
#test(value) ⇒ Object
26 27 28 29 |
# File 'lib/rules/boolean_rule.rb', line 26 def test(value) # Booleans are stored as strings. @booleans.include? value.to_s end |
#train(meta) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rules/boolean_rule.rb', line 15 def train() value = [:value] unless value.nil? @booleans << value end end |