Skip to content

Instantly share code, notes, and snippets.

@bradland
Created Jul 17, 2021
Embed
What would you like to do?
r/ruby question
A12345 Jon Osterman
A23456 Walter Kovacs
A34567 Daniel Dreiberg
987 Dr. Manhattan
876 Rorshach
765 Night Owl
A12345 987
A23456 876
A34567 765
# From https://www.reddit.com/r/ruby/comments/om585d/question_on_reading_text_file_into_array_of_class/
# User class to hold array of users. Each user object holds User ID and Name
class User
@@uArray = []
attr :user_id, :user_name
def self.all_instances
@@uArray
end
def initialize(uID, uName)
@user_id = uID
@user_name = uName
@@uArray << self
end
end
# Hero class to hold Hero ID and Name
class Hero
def initialize(hID, hName)
@hero_id = hID
@hero_name = hName
end
end
# Seat class to hold User ID and Hero ID
class Seat
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment