Class: Cellula::AutomatonBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cellula/automaton_builder.rb

Overview

Public: Provides an interface to build Automaton objects.

Examples

ca = AutomatonBuilder.new("my name").build
ca = AutomatonBuilder.new("my name").dimensions(2).build

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ AutomatonBuilder

Public: Initialize an new AutomatonBuilder.

name - String name of the futur Automaton.



14
15
16
17
18
19
20
# File 'lib/cellula/automaton_builder.rb', line 14

def initialize(name)
  @name = name
  @dimensions = 1
  @type = :elementary
  @width = 20
  @rule = :wolfram_code_110
end

Instance Method Details

#buildObject

Public: Builds an Automaton with characteristics given with the setters methods.

Returns Automaton.



50
51
52
# File 'lib/cellula/automaton_builder.rb', line 50

def build
  Automaton.new(@name, @dimensions, @type, @width, @rule)
end

#dimensions(val) ⇒ Object

Public: Set the Integer dimensions of the automaton’s grid. Default is 1.

Returns self.



26
# File 'lib/cellula/automaton_builder.rb', line 26

def dimensions(val); @dimensions = val; self; end

#rule(val) ⇒ Object

Public: Set the rule of the automaton. Default is :wolfram_code_110.

Returns self.



44
# File 'lib/cellula/automaton_builder.rb', line 44

def rule(val); @rule = val; self; end

#type(val) ⇒ Object

Public: Set the Symbol type of the automaton. Default is :elementary.

Returns self.



32
# File 'lib/cellula/automaton_builder.rb', line 32

def type(val); @type = val; self; end

#width(val) ⇒ Object

Public: Set the Integer width of the automaton’s grid. Default is 20.

Returns self.



38
# File 'lib/cellula/automaton_builder.rb', line 38

def width(val); @width = val; self; end