# How to use a class

**URL:** <https://www.ruby-forum.com/t/how-to-use-a-class/71452>\
**Category:** Ruby\
**Created:** [October 9, 2006, 12:51am UTC](https://www.ruby-forum.com/t/how-to-use-a-class/71452 "2006-10-09T00:51:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 9, 2006, 12:51am UTC](https://www.ruby-forum.com/t/how-to-use-a-class/71452/1 "2006-10-09T00:51:41Z")

</div>

Hi guys,

Thank you all for taking your time and replying my previous post.

Now I have other questions: 1) After I write a class with some methods I  
want to save the file called test. Which extension is associated with  
this file(test.rb or else)? How do I create a new object from the file  
called test from another script? (I check the online book of programming  
Ruby but just can’t find information yet)

2)Which method is used globally for the following substitution ?  
s1=“AATTCCGG” # original string  
s2=“TTAAGGCC” # expected string, which means A-\>T, T-\>A, C-\>G, G-\>C

Li

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 9, 2006, 12:58am UTC](https://www.ruby-forum.com/t/how-to-use-a-class/71452/2 "2006-10-09T00:58:33Z")

</div>

Li Chen wrote:

> Now I have other questions: 1) After I write a class with some methods I  
> want to save the file called test. Which extension is associated with  
> this file(test.rb or else)? How do I create a new object from the file  
> called test from another script?

You save the file as test.rb, and then in the other file, use:  
require ‘test’  
to be able to use classes in it.

> 2)Which method is used globally for the following substitution ?  
> s1=“AATTCCGG” # original string  
> s2=“TTAAGGCC” # expected string, which means A-\>T, T-\>A, C-\>G, G-\>C

irb(main):001:0\> “AATTCCGG”.tr(“ATCG”, “TAGC”)  
=\> “TTAAGGCC”

David V.

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [October 9, 2006, 1:10am UTC](https://www.ruby-forum.com/t/how-to-use-a-class/71452/3 "2006-10-09T01:10:39Z")

</div>

David V. wrote:

> Li Chen wrote:
> 
> > Now I have other questions: 1) After I write a class with some methods I  
> > want to save the file called test. Which extension is associated with  
> > this file(test.rb or else)? How do I create a new object from the file  
> > called test from another script?
> 
> You save the file as test.rb, and then in the other file, use:  
> require ‘test’  
> to be able to use classes in it.
> 
> > 2)Which method is used globally for the following substitution ?  
> > s1=“AATTCCGG” # original string  
> > s2=“TTAAGGCC” # expected string, which means A-\>T, T-\>A, C-\>G, G-\>C
> 
> irb(main):001:0\> “AATTCCGG”.tr(“ATCG”, “TAGC”)  
> =\> “TTAAGGCC”
> 
> David V.

Thanks David,

Li
