Created
July 17, 2021 15:38
-
-
Save bradland/9a6de8cdf71fae271bb461beb460c5b8 to your computer and use it in GitHub Desktop.
r/ruby question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A12345 Jon Osterman | |
A23456 Walter Kovacs | |
A34567 Daniel Dreiberg | |
987 Dr. Manhattan | |
876 Rorshach | |
765 Night Owl | |
A12345 987 | |
A23456 876 | |
A34567 765 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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