Class: Whitespace::Memory
- Inherits:
-
Object
- Object
- Whitespace::Memory
- Defined in:
- lib/whitespace/data_structures/memory.rb
Instance Method Summary collapse
- #[](address) ⇒ Object
- #[]=(address, value) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
3 4 5 |
# File 'lib/whitespace/data_structures/memory.rb', line 3 def initialize @store = {} end |
Instance Method Details
#[](address) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/whitespace/data_structures/memory.rb', line 7 def [](address) if @store.key?(address) @store[address] else raise AddressError, "no such address exists: #{address}" end end |
#[]=(address, value) ⇒ Object
15 16 17 |
# File 'lib/whitespace/data_structures/memory.rb', line 15 def []=(address, value) @store[address] = value end |