Class: Reflekt::ObjectRule
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#initialize ⇒ ObjectRule
constructor
A new instance of ObjectRule.
- #random ⇒ Object
- #result ⇒ Object
- #test(value) ⇒ Object
- #train(meta) ⇒ Object
Constructor Details
#initialize ⇒ ObjectRule
Returns a new instance of ObjectRule.
6 7 8 9 10 11 |
# File 'lib/rules/object_rule.rb', line 6 def initialize() @type = :object @class_type = nil # TODO: Populate with meta for each arg. @class_args = [] end |
Instance Method Details
#random ⇒ Object
36 37 38 39 |
# File 'lib/rules/object_rule.rb', line 36 def random() # TODO: Instantiate class with appropriate @class_args metadata. eval("#{@class_type}").new() end |
#result ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rules/object_rule.rb', line 29 def result() { :type => @type, :class_type => @class_type } end |
#test(value) ⇒ Object
25 26 27 |
# File 'lib/rules/object_rule.rb', line 25 def test(value) value.class.to_s == @class_type end |
#train(meta) ⇒ Object
16 17 18 19 20 |
# File 'lib/rules/object_rule.rb', line 16 def train() if @class_type.nil? @class_type = [:class_type] end end |