Class: Binary_Puzzle_Solver::Cell
- Inherits:
-
Object
- Object
- Binary_Puzzle_Solver::Cell
- Defined in:
- lib/binary_puzzle_solver/base.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #get_char ⇒ Object
-
#initialize(params = {}) ⇒ Cell
constructor
A new instance of Cell.
- #set_state(new_state) ⇒ Object
Constructor Details
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
60 61 62 |
# File 'lib/binary_puzzle_solver/base.rb', line 60 def state @state end |
Instance Method Details
#get_char ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/binary_puzzle_solver/base.rb', line 83 def get_char() if state == ZERO return '0' elsif state == ONE return '1' else raise RuntimeError, "get_char() called on Unset state" end end |
#set_state(new_state) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/binary_puzzle_solver/base.rb', line 71 def set_state (new_state) if (not VALID_STATES.has_key?(new_state)) raise RuntimeError, "Invalid state " + new_state.to_s; end if (@state != UNKNOWN) raise RuntimeError, "Cannot reassign a value to the already set state." end @state = new_state return end |