[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to use a class

Li Chen

10/8/2006 10:52:00 PM

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






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

2 Answers

David Vallner

10/8/2006 10:57:00 PM

0

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 Vallner

Li Chen

10/8/2006 11:11:00 PM

0

David Vallner 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 Vallner

Thanks David,

Li

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