Module: Cellula
- Defined in:
- lib/cellula.rb,
lib/cellula/study.rb,
lib/cellula/automaton.rb,
lib/cellula/rules/rule.rb,
lib/cellula/study_builder.rb,
lib/cellula/automaton_builder.rb,
lib/cellula/rules/wolfram_code_rule.rb
Overview
Public: Cellula is a framework for building, running and studying cellular automata. For this, Cellula provides a simple DSL.
Following is an example of Cellula DSL:
automaton "his name" do
dimension 1
type :elementary
width 20
rule :wolfram_code_110
end
Save the previous example in a file named `my_automaton.rb` and
launch it with:
cellula path/to/my_automaton.rb
Defined Under Namespace
Classes: Automaton, AutomatonBuilder, Rule, Study, StudyBuilder, WolframCodeRule
Instance Method Summary collapse
-
#automaton(name, &block) ⇒ Object
Internal: Part of the DSL API, this method builds a new Automaton object via AutomatonBuilder.
-
#banner ⇒ Object
Public: Display a banner on stdout.
-
#panic(message = "Unknown error") ⇒ Object
Public: Print an error message and exit with code 1.
-
#study(name, &block) ⇒ Object
Internal: Part of the DSL API, this method builds a new Study object via StudyBuilder.
-
#usage ⇒ Object
Public: Display application’s usage on stdout.
Instance Method Details
#automaton(name, &block) ⇒ Object
Internal: Part of the DSL API, this method builds a new Automaton object via AutomatonBuilder.
name - String name of the automaton. block - A Ruby block to build the automaton.
Returns nothing.
33 34 35 |
# File 'lib/cellula.rb', line 33 def automaton(name, &block) @auto = Docile.dsl_eval(AutomatonBuilder.new(name), &block).build end |
#banner ⇒ Object
Public: Display a banner on stdout.
Returns nothing.
51 52 53 54 |
# File 'lib/cellula.rb', line 51 def puts "Cellula version " + File.read('VERSION').strip puts "" end |
#panic(message = "Unknown error") ⇒ Object
Public: Print an error message and exit with code 1.
message - The String message to display to user before exiting.
Returns nothing.
72 73 74 75 76 |
# File 'lib/cellula.rb', line 72 def panic( = "Unknown error") puts "** Panic **" puts exit(1) end |
#study(name, &block) ⇒ Object
Internal: Part of the DSL API, this method builds a new Study object via StudyBuilder.
name - String name of the automaton to study. block - A Ruby block to build the automaton.
Returns nothing.
44 45 46 |
# File 'lib/cellula.rb', line 44 def study(name, &block) @study = Docile.dsl_eval(StudyBuilder.new(name), &block).build end |
#usage ⇒ Object
Public: Display application’s usage on stdout.
Returns nothing.
59 60 61 62 63 64 65 |
# File 'lib/cellula.rb', line 59 def usage puts " usage: cellula path/to/automaton_file.rb " end |