Class: Cauldron::Builder
- Inherits:
-
Object
- Object
- Cauldron::Builder
- Defined in:
- lib/cauldron/builder.rb
Instance Attribute Summary collapse
-
#composite ⇒ Object
readonly
Returns the value of attribute composite.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(composite) ⇒ Builder
constructor
A new instance of Builder.
-
#insertable_operators(examples) ⇒ Object
NOTE: returns an array of new actualized composites extending the current composite.
- #tree ⇒ Object
Constructor Details
#initialize(composite) ⇒ Builder
Returns a new instance of Builder.
7 8 9 |
# File 'lib/cauldron/builder.rb', line 7 def initialize(composite) @composite = composite end |
Instance Attribute Details
#composite ⇒ Object (readonly)
Returns the value of attribute composite.
5 6 7 |
# File 'lib/cauldron/builder.rb', line 5 def composite @composite end |
Class Method Details
.available_statement_types ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cauldron/builder.rb', line 33 def self.available_statement_types # CURRENT # StatementGenerator.new.build( # ['A','B', 'AC'], # [:collect] # )+Cauldron::StatementGenerator.new.build('string',[:chop]) # TRYING # StatementGenerator.new.build( # ['A','B', 'AC'], # [:collect] # )+Cauldron::StatementGenerator.new.build('string',[:chop])+[Cauldron::ArrayCollectTemplate::Template] [StatementGenerator.new.build_template( ['A','B', 'AC'], :collect ).statement_classes.first]+[Cauldron::StatementGenerator.new.build_template('string',:chop).statement_classes.first]+[Cauldron::ArrayCollectTemplate::Template]+[Cauldron::NumberAdditionTemplate::Template] # TODO Not very effient to regenerate the opperators # StatementGenerator.new.build( # ['A','B', 'AC'], # [:collect] # )+Cauldron::StatementGenerator.new.build('string',[:chop])+[ArrayReverseOperator]+[StatementGenerator.new.build(3,[:+])] end |
Instance Method Details
#insertable_operators(examples) ⇒ Object
NOTE: returns an array of new actualized composites extending the current composite
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cauldron/builder.rb', line 22 def insertable_operators(examples) actualized_composite = ActualizedComposite.new(composite.clone_solution, examples) h = actualized_composite.histories results = self.class.available_statement_types.inject([]) do |total,x| total += x.instances(h, composite, examples, h.insert_points) total end #binding.pry results end |
#tree ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/cauldron/builder.rb', line 11 def tree root_node = Tree::TreeNode.new("ROOT", "Root Content") line_count = 0 composite.operators.each do |x| child_node = Tree::TreeNode.new('CHILD-'+line_count.to_s) root_node << child_node line_count += 1 end end |