Help with initialize method that involves readlines

i’m trying to set up a list or library of sorts that holds the info for
the objects in my program. Since i am working with atoms and molecules i
know all of the possible parameters, as in an atom with an atomic number
of 1 has to be hydrogen and the abbreviation has to be H. i feel like i
can set up my initialize method to read a specified line in an outside
file and use it for the @variables. i have an idea of how the process
would go but don’t know how to write it out yet. below is
what i have in mind but it should be obvious where i’m confused because
i just describe what i want in human words

class Atom
def initialize(x)
open(atom_name.txt, atom_abr.txt)readlines(x)
@atom_name = line x of atom_name.txt
@abbreviation = line x of atom_abr.txt
end
end
x will be a number 1 through 118

On Feb 23, 2013 5:54 PM, “Jordan G.” [email protected] wrote:

Posted via http://www.ruby-forum.com/.

Look into yaml files

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs