# Help with initialize method that involves readlines

**URL:** <https://www.ruby-forum.com/t/help-with-initialize-method-that-involves-readlines/226870>\
**Category:** Ruby\
**Created:** [February 24, 2013, 12:52am UTC](https://www.ruby-forum.com/t/help-with-initialize-method-that-involves-readlines/226870 "2013-02-24T00:52:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thelieber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@thelieber](https://www.ruby-forum.com/u/thelieber)\
**Post date:** [February 24, 2013, 12:52am UTC](https://www.ruby-forum.com/t/help-with-initialize-method-that-involves-readlines/226870/1 "2013-02-24T00:52:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thelieber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@thelieber](https://www.ruby-forum.com/u/thelieber)\
**Post date:** [February 24, 2013, 6:58am UTC](https://www.ruby-forum.com/t/help-with-initialize-method-that-involves-readlines/226870/2 "2013-02-24T06:58:49Z")

</div>

On Feb 23, 2013 5:54 PM, “Jordan G.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Look into yaml files
