[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Very rank beginner.

Claude Van Horn

1/13/2009 9:29:00 PM

Help. I am a really new beginner looking at Ruby for the first time.
I was trying to go through the tutorial "Ruby in 20 minutes" on a Windows XP
machine using fxri.

Some of the code does not work as in the examples. Who should I ask for
help?

Thanks for any suggestions (even flames are welcome )

Van!!


9 Answers

Tim Greer

1/13/2009 9:53:00 PM

0

Ropebender wrote:

> Help. I am a really new beginner looking at Ruby for the first time.
> I was trying to go through the tutorial "Ruby in 20 minutes" on a
> Windows XP machine using fxri.
>
> Some of the code does not work as in the examples. Who should I ask
> for help?
>
> Thanks for any suggestions (even flames are welcome )
>
> Van!!

What site were you using the ruby tutorial from? What parts of the code
didn't work, what were the problems or errors? If you've tried the
code and searched for answers, then you'd probably ask here.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Claude Van Horn

1/13/2009 11:31:00 PM

0

The tutorial was on http://www.ruby...

It was the tutorial in the sidebar "Ruby in 20 minutes"

Worked fine until I tried to define a class Greeter. Instructions said to
initialize Greeter with (name = "World") and then define an object g to set
the @name. It didn't woork like the tutorial said.

=> nil

irb(main):033:0> class Greeter

irb(main):034:1> def initialize(name = "World")

irb(main):035:2> end

irb(main):036:1> def say_hi

irb(main):037:2> puts "Hi #{@name}!"

irb(main):038:2> end

irb(main):039:1> def say_bye

irb(main):040:2> puts "Bye #{@name}!"

irb(main):041:2> end

irb(main):042:1> end

=> nil

irb(main):043:0> g = Greeter.new("Pat")

=> #<Greeter:0x63075a4>

irb(main):044:0> g.say_hi

Hi !

=> nil

irb(main):061:0> g = Greeter.new("Andy")

=> #<Greeter:0x62e3924>

irb(main):062:0> g

=> #<Greeter:0x62e3924>

irb(main):063:0>





Looks like the initialize never worked. Any suggestions?







"Tim Greer" <tim@burlyhost.com> wrote in message
news:H28bl.10476$qi.9172@newsfe09.iad...
> Ropebender wrote:
>
>> Help. I am a really new beginner looking at Ruby for the first time.
>> I was trying to go through the tutorial "Ruby in 20 minutes" on a
>> Windows XP machine using fxri.
>>
>> Some of the code does not work as in the examples. Who should I ask
>> for help?
>>
>> Thanks for any suggestions (even flames are welcome )
>>
>> Van!!
>
> What site were you using the ruby tutorial from? What parts of the code
> didn't work, what were the problems or errors? If you've tried the
> code and searched for answers, then you'd probably ask here.
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!


pjb

1/13/2009 11:37:00 PM

0

"Ropebender" <ropebender@sbcglobal.net> writes:

> The tutorial was on http://www.ruby...
>
> It was the tutorial in the sidebar "Ruby in 20 minutes"
>
> Worked fine until I tried to define a class Greeter. Instructions said to
> initialize Greeter with (name = "World") and then define an object g to set
> the @name. It didn't woork like the tutorial said.
>
> => nil
>
> irb(main):033:0> class Greeter
>
> irb(main):034:1> def initialize(name = "World")
>
> irb(main):035:2> end
>
> Looks like the initialize never worked. Any suggestions?

Indeed. def initialize(name = "World") doesn't initialize anything.
It just says that if you don't give any argument to new, then it should
do as if you passwed "World", and set the parameter accordingly.

You didn't do anything with this parameter.
Try to add a
@name = name
somewhere...


--
__Pascal Bourguignon__

Claude Van Horn

1/13/2009 11:54:00 PM

0

Sure enough ..

I left that line out. In the tutorial, the "@name" was in blue, and I
interpreted it as a response from ruby rather than a line I type in. Sorry
for the error. I have a LOT to learn :)

"Pascal J. Bourguignon" <pjb@informatimago.com> wrote in message
news:87k58y6amg.fsf@informatimago.com...
> "Ropebender" <ropebender@sbcglobal.net> writes:
>
>> The tutorial was on http://www.ruby...
>>
>> It was the tutorial in the sidebar "Ruby in 20 minutes"

> Try to add a
> @name = name
> somewhere...


Tim Greer

1/14/2009 12:52:00 AM

0

Ropebender wrote:

> Sure enough ..
>
> I left that line out.  In the tutorial, the "@name" was in blue, and I
> interpreted it as a response from ruby rather than a line I type in. 
> Sorry for the error.  I have a LOT to learn :)>

No need to apologize, sometimes it just takes some patience or an extra
set of eyes to find the problem. I've seen a lot of professional
coders about throw their system out the window (literally) because of a
simple thing they were missing after a day of coding with no breaks.
Sometimes you have to take a break and look at it with fresh eyes.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Phlip

1/14/2009 3:36:00 AM

0

> irb(main):033:0> class Greeter

Don't use irb. If you use Windows, the One Click Installer comes with SciTE.exe.
Run that, and it will run your ruby for you each time you hit <F5>.

Claude Van Horn

1/14/2009 5:18:00 PM

0

Thanks for the tip ... Another question:

When I write an xxx.rb program in Notebook and try to run it, the cmd
window will not stay open. On earlier versions of Windows you could make a
..pif file to control if the window stayed open or closed, but in XP it seems
they have taken that away. I looked up all the commands and opening
perameters I could find and can't seem to find one that will cause the CMD
window to wtay open after the program runs so I can see the results. I
either need to do that, or redirect the output to LPT1 so I can see what I
did. Does SciTE allow you to read in and run a program from a file?

Thanks !

Van!!

"Phlip" <phlip2005@gmail.com> wrote in message
news:p4dbl.17653$Ws1.11925@nlpi064.nbdc.sbc.com...
>> irb(main):033:0> class Greeter
>
> Don't use irb. If you use Windows, the One Click Installer comes with
> SciTE.exe. Run that, and it will run your ruby for you each time you hit
> <F5>.


Claude Van Horn

1/14/2009 5:28:00 PM

0

Now I see, SciTE is an excelent looking universal Text Editor :) What a
find! I would have never found it but for your hint. Thanks loads! SciTE
will help in lots of ways.. Notebook -- never again :))

That answered the second question too, no, you can't run the program from a
text editor, Silly me. So I am left with the last one: how to keep the
blasted window open or redirect the output.

Van!!
"Ropebender" <ropebender@sbcglobal.net> wrote in message
news:Rbpbl.8927$pr6.543@flpi149.ffdc.sbc.com...
> Thanks for the tip ... Another question:
>
> When I write an xxx.rb program in Notebook and try to run it, the cmd
> window will not stay open. On earlier versions of Windows you could make
> a .pif file to control if the window stayed open or closed, but in XP it
> seems they have taken that away. I looked up all the commands and opening
> perameters I could find and can't seem to find one that will cause the CMD
> window to wtay open after the program runs so I can see the results. I
> either need to do that, or redirect the output to LPT1 so I can see what I
> did. Does SciTE allow you to read in and run a program from a file?
>
> Thanks !
>
> Van!!
>
> "Phlip" <phlip2005@gmail.com> wrote in message
> news:p4dbl.17653$Ws1.11925@nlpi064.nbdc.sbc.com...
>>> irb(main):033:0> class Greeter
>>
>> Don't use irb. If you use Windows, the One Click Installer comes with
>> SciTE.exe. Run that, and it will run your ruby for you each time you hit
>> <F5>.
>
>


Claude Van Horn

1/14/2009 5:48:00 PM

0

A very rank beginner that doesn't follow instructions! F5 you say. Thanks
!! It works. Now all I have to do is learn the language.


"Phlip" <phlip2005@gmail.com> wrote in message
news:p4dbl.17653$Ws1.11925@nlpi064.nbdc.sbc.com...
>> irb(main):033:0> class Greeter
>
> Don't use irb. If you use Windows, the One Click Installer comes with
> SciTE.exe. Run that, and it will run your ruby for you each time you hit
> <F5>.