Class: Lifelike::LifelikeCellularAutomaton::Rules
- Inherits:
-
Object
- Object
- Lifelike::LifelikeCellularAutomaton::Rules
- Defined in:
- lib/lifelike/lifelike_cellular_automaton/rules.rb
Instance Method Summary collapse
- #born?(alive_neighbor_count) ⇒ Boolean
-
#initialize(string) ⇒ Rules
constructor
A new instance of Rules.
- #survives?(alive_neighbor_count) ⇒ Boolean
Constructor Details
#initialize(string) ⇒ Rules
Returns a new instance of Rules.
4 5 6 |
# File 'lib/lifelike/lifelike_cellular_automaton/rules.rb', line 4 def initialize(string) @rule_string = RuleString.new(string) end |
Instance Method Details
#born?(alive_neighbor_count) ⇒ Boolean
12 13 14 |
# File 'lib/lifelike/lifelike_cellular_automaton/rules.rb', line 12 def born?(alive_neighbor_count) @rule_string.alive_neighbors_to_be_born.include?(alive_neighbor_count) end |
#survives?(alive_neighbor_count) ⇒ Boolean
8 9 10 |
# File 'lib/lifelike/lifelike_cellular_automaton/rules.rb', line 8 def survives?(alive_neighbor_count) @rule_string.alive_neighbors_to_survive.include?(alive_neighbor_count) end |