Hey everyone. Trying to take a simple test.txt file and seperate the text and integers after its read in for array manipulation. The idea is to be able to use/require the attr_accessor from the seperate Person class. So I can use :name, :hair_color, :gender
For example lets says we have in our text file which is all seperated by the tab delimiter, for shortness I just used space:
Bob red_hair 38
Joe brown_hair 39
John black_hair 40
My class would read something like:
class Person
attr_accessor :name, :hair_color, :gender
def initialize
@place_holder = 'test'
end
def to_s
@test_string = 'test a string'
end
end
My main file that I'm having strategy issues with so far:
test_my_array = File.readlines('test.txt').each('\t') #having trouble with
I'm pretty sure its easier to manipulate line by line rather then one file. I'm not sure where to go after that. I know I need to seperate my data some how for :name, :hair_color, :gender. Throw some code up so I can try things out.
Thanks for the help!