Class: Cellula::StudyBuilder
- Inherits:
-
Object
- Object
- Cellula::StudyBuilder
- Defined in:
- lib/cellula/study_builder.rb
Overview
Public: Provides an interface to build Study objects.
Examples
ca = StudyBuilder.new("CA name").build
ca = StudyBuilder.new("CA name").generations(99).build
Instance Method Summary collapse
-
#build ⇒ Object
Public: Builds a Study with characteristics given with the setters methods.
-
#generations(val) ⇒ Object
Public: Set the Integer number of generations to study.
-
#initialize(ca_name) ⇒ StudyBuilder
constructor
Public: Initialize an new StudyBuilder.
-
#method(val) ⇒ Object
Public: Set the Symbol method of study.
Constructor Details
#initialize(ca_name) ⇒ StudyBuilder
Public: Initialize an new StudyBuilder.
ca_name - String name of the cellular automaton that the Study
wants to study.
15 16 17 18 19 |
# File 'lib/cellula/study_builder.rb', line 15 def initialize(ca_name) @ca_name = ca_name @method = :random @generations = 10 end |
Instance Method Details
#build ⇒ Object
Public: Builds a Study with characteristics given with the setters methods.
Returns Study.
37 38 39 |
# File 'lib/cellula/study_builder.rb', line 37 def build Study.new(@ca_name, @method, @generations) end |
#generations(val) ⇒ Object
Public: Set the Integer number of generations to study. Default is 10.
Returns self.
31 |
# File 'lib/cellula/study_builder.rb', line 31 def generations(val); @generations = val; self; end |
#method(val) ⇒ Object
Public: Set the Symbol method of study. Default is :random.
Returns self.
25 |
# File 'lib/cellula/study_builder.rb', line 25 def method(val); @method = val; self; end |