Working hard, decided that we need to commit to Git

This commit is contained in:
2025-10-02 14:57:16 -06:00
commit 72bd5fb9c0
11 changed files with 659 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# Nathan Hinton 1 Oct 2025
# Create a custom hash class for the universe.
# This will contain the universe hash inside it. It will allow for array type
# indexing as well as point type indexing
class UniverseHash
def initialize()
@universe_hash = {}
end
# Setter for values in the hash
def =[](key, value)
if key.class == Array
@universe_hash[key[0]] = {} if @universe_hash[key[0]].nil?
@universe_hash[key[0]][key[1]] = {} if @universe_hash[key[0]][key[1]].nil?
@universe_hash[key[0]][key[1]][key[2]] = value
else
raise NotImplementedError.new('You can only set based on point values.')
end
end
def [](key)
if key.class == Array
return @universe_hash[key[0]][key[1]][key[2]]
elsif key.class == Integer
return @universe_hash[key]
else
raise NotImplementedError
end
end
end