Difference between revisions of "Render Part D Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 9: Line 9:
 
module Composite should define methods push_component and each_component as well as include the [https://ruby-doc.org/core-2.6.3/Enumerable.html Enumerable] module.
 
module Composite should define methods push_component and each_component as well as include the [https://ruby-doc.org/core-2.6.3/Enumerable.html Enumerable] module.
 
===push_component===
 
===push_component===
 +
 
===each_component===
 
===each_component===
 
if a block is given, yield for each component.  otherwise return [https://ruby-doc.org/core-2.6.3/Object.html#method-i-to_enum a new Enumerator] of the components.
 
if a block is given, yield for each component.  otherwise return [https://ruby-doc.org/core-2.6.3/Object.html#method-i-to_enum a new Enumerator] of the components.
 +
 +
===Enumerable===
 +
to make use of the methods in the [https://ruby-doc.org/core-2.6.3/Enumerable.html Enumerable] module, use [https://www.rubydoc.info/stdlib/core/Module:alias_method alias_method] to alias an <code>:each</code> method to the <code>:each_component </code> method.
  
 
==CompositeTransform==
 
==CompositeTransform==

Revision as of 13:16, 3 August 2019

In this studio we will evolve our code from Render_Part_C_Assignment to leverage mixins.

Render part d class hierarchy.svg

Continue editing files in the render/assignment directory.

Code to Implement

Composite

module Composite should define methods push_component and each_component as well as include the Enumerable module.

push_component

each_component

if a block is given, yield for each component. otherwise return a new Enumerator of the components.

Enumerable

to make use of the methods in the Enumerable module, use alias_method to alias an :each method to the :each_component method.

CompositeTransform

include Composite and clean up existing code.

Scene

include Composite and clean up existing code.