Skip to content

Instantly share code, notes, and snippets.

@bradland
Created July 17, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradland/9a6de8cdf71fae271bb461beb460c5b8 to your computer and use it in GitHub Desktop.
Save bradland/9a6de8cdf71fae271bb461beb460c5b8 to your computer and use it in GitHub Desktop.
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