S
Sean Hussey
Hi everone,
I'm not quite sure what the best way to go about this is. I have a
file with one user per line. Each line contains ID, username, phone,
etc. I split all these up into variables and then either create a new
user or update an existing user:
File.open("users.txt", "r") do |file|
file.each_line { |line|
id, username, phone, lots, more, variables = line.chomp.split(/\|/);
if user = ldap.get_entry(username)
# Existing user. Check for update.
user.update(I, hate, passing, all, of, the, variables, that,
were, just, split)
else
# New user. Create!
user.new(Same, here, see, what, I mean?)
end
}
end
Should I put it all into an array? Hash? Would that make the split
line huge but save space on the method calls? How would you go about
this?
Thank you!
Sean
I'm not quite sure what the best way to go about this is. I have a
file with one user per line. Each line contains ID, username, phone,
etc. I split all these up into variables and then either create a new
user or update an existing user:
File.open("users.txt", "r") do |file|
file.each_line { |line|
id, username, phone, lots, more, variables = line.chomp.split(/\|/);
if user = ldap.get_entry(username)
# Existing user. Check for update.
user.update(I, hate, passing, all, of, the, variables, that,
were, just, split)
else
# New user. Create!
user.new(Same, here, see, what, I mean?)
end
}
end
Should I put it all into an array? Hash? Would that make the split
line huge but save space on the method calls? How would you go about
this?
Thank you!
Sean