Class: Lifelike::LifelikeCellularAutomaton::WorldStringAnalyzer
- Inherits:
-
Object
- Object
- Lifelike::LifelikeCellularAutomaton::WorldStringAnalyzer
- Defined in:
- lib/lifelike/lifelike_cellular_automaton/world_string_analyzer.rb
Instance Method Summary collapse
- #alive_char ⇒ Object
- #dead_char ⇒ Object
-
#initialize(string, default_dead_char: ' ', default_alive_char: 'X') ⇒ WorldStringAnalyzer
constructor
A new instance of WorldStringAnalyzer.
Constructor Details
#initialize(string, default_dead_char: ' ', default_alive_char: 'X') ⇒ WorldStringAnalyzer
Returns a new instance of WorldStringAnalyzer.
4 5 6 7 8 |
# File 'lib/lifelike/lifelike_cellular_automaton/world_string_analyzer.rb', line 4 def initialize(string, default_dead_char: ' ', default_alive_char: 'X') @world_string = string @default_dead_char = default_dead_char @default_alive_char = default_alive_char end |
Instance Method Details
#alive_char ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lifelike/lifelike_cellular_automaton/world_string_analyzer.rb', line 21 def alive_char case valid_chars.size when 0 fail InsufficientValidCharacterError.new(allowed_chars_by_aliveness) when 1 lifelike_char || @default_alive_char else most_alive_valid_char end end |
#dead_char ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/lifelike/lifelike_cellular_automaton/world_string_analyzer.rb', line 10 def dead_char case valid_chars.size when 0 fail InsufficientValidCharacterError.new(allowed_chars_by_aliveness) when 1 deadlike_char || @default_dead_char else least_alive_valid_char end end |