New

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
       from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

···

--
fish can't fly but birds can
birds can't swim but fish can

You need to type "ruby hello.rb" from the command line rather than inside of
irb.

···

On 4/17/07, poison tooth <fixxie.wits@gmail.com> wrote:

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
       from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

--
fish can't fly but birds can
birds can't swim but fish can

--
"Hey brother christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

if your in a linux computer, you may need this at the beginning of your
program

#!/usr/bin/env ruby

or

#!/usr/bin/ruby

also may need to make the file executatble by

chmod a+x /path/to/your/program.rb

hth

···

On 4/17/07, poison tooth <fixxie.wits@gmail.com> wrote:

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
       from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

--
fish can't fly but birds can
birds can't swim but fish can

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
      from (irb):1
irb(main):002:0> "

Try running "ruby hello.rb" from a Terminal window (on a Mac) instead of from irb.
If you want to run it from irb, enter "load 'hello.rb'".

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

You can use any text editor. TextEdit should be fine, but there are many better choices. I see you're on a Mac. Check out TextMate.

···

On Apr 17, 2007, at 12:22 PM, poison tooth wrote:

Since you mention TextEdit, I presume you are on a Mac. Also, since you mention irb, I presume you are familiar with Terminal. Here is an easy way to run a Ruby script in Terminal. After writing your hello script in TextEdit save it as hello.rb. Now in terminal at a fresh prompt, type "ruby " (without the quotes and remember to include the space after "ruby"). Now drag hello.rb into to Terminal and hit return. The text "Hello World" should appear.

Regards, Morton

···

On Apr 17, 2007, at 1:22 PM, poison tooth wrote:

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
      from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

poison tooth wrote:

Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

If you just want to make sure that you can run that book example, here
is a quick low-level solution. In a terminal, run:

  echo 'puts "Hello World"' > hello.rb
  ruby hello.rb

Alternatively, you can run:

  ruby -e 'puts "Hello World"'

As for your program editing troubles, I suggest having a look at the
Ruby garden (skip down to the "Ruby development environments" section):

  http://wiki.rubygarden.org/Ruby/page/show/RubyOnMacintosh

···

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

if u r in the learning phase ,then just try scite editor.it is the best one.

···

On 4/17/07, poison tooth <fixxie.wits@gmail.com> wrote:

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
       from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

--
fish can't fly but birds can
birds can't swim but fish can

oops, did not read your email well enough.

dont use MS word, use notepad or something
MS word puts a lot of formatting stuff in the file
hth.

sk

···

On 4/17/07, shawn bright <nephish@gmail.com> wrote:

if your in a linux computer, you may need this at the beginning of your
program

#!/usr/bin/env ruby

or

#!/usr/bin/ruby

also may need to make the file executatble by

chmod a+x /path/to/your/program.rb

hth

On 4/17/07, poison tooth <fixxie.wits@gmail.com> wrote:
>
> Im just learning ruby and im stuck the guide im using says
>
> "Your first program
> Congratulations! Now that you have made it this far, you are ready to
> start writing programs.
> Hello World
> Grab a text editor and type in the following:
>
> puts "Hello World"
>
> Save the file as hello.rb and run it by typing
> ruby hello.rb"
>
> i've tried that more than once and it says the out is:
>
> "irb(main):001:0> ruby hello.rb
> NameError: undefined local variable or method `hello' for main:Object
> from (irb):1
> irb(main):002:0> "
>
> the guide never said what word processor should i use
> i tried TextEdit.app but it fussed about the .rb
> so i used Microsoft word and this is what it does...
>
> Any tips?
>
> --
> fish can't fly but birds can
> birds can't swim but fish can
>

Also, there is one more possible source of trouble. TextEdit must be in Plain Text mode when you save a Ruby script. If it's in Rich Text mode, hit cmnd-shift-T to change the mode before you save.

Regards, Morton

···

On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:

On Apr 17, 2007, at 1:22 PM, poison tooth wrote:

Im just learning ruby and im stuck the guide im using says

"Your first program
Congratulations! Now that you have made it this far, you are ready to
start writing programs.
Hello World
Grab a text editor and type in the following:

puts "Hello World"

Save the file as hello.rb and run it by typing
ruby hello.rb"

i've tried that more than once and it says the out is:

"irb(main):001:0> ruby hello.rb
NameError: undefined local variable or method `hello' for main:Object
      from (irb):1
irb(main):002:0> "

the guide never said what word processor should i use
i tried TextEdit.app but it fussed about the .rb
so i used Microsoft word and this is what it does...

Any tips?

Since you mention TextEdit, I presume you are on a Mac. Also, since you mention irb, I presume you are familiar with Terminal. Here is an easy way to run a Ruby script in Terminal. After writing your hello script in TextEdit save it as hello.rb. Now in terminal at a fresh prompt, type "ruby " (without the quotes and remember to include the space after "ruby"). Now drag hello.rb into to Terminal and hit return. The text "Hello World" should appear.

i know quite a bit of unix so thats not a problem and i can also ask
my dad (but he dosent know ruby) :{

···

On 4/19/07, hemant sonker <hemant0070@gmail.com> wrote:

if u r in the learning phase ,then just try scite editor.it is the best one.
On 4/17/07, poison tooth <fixxie.wits@gmail.com> wrote:
>
> Im just learning ruby and im stuck the guide im using says
>
> "Your first program
> Congratulations! Now that you have made it this far, you are ready to
> start writing programs.
> Hello World
> Grab a text editor and type in the following:
>
> puts "Hello World"
>
> Save the file as hello.rb and run it by typing
> ruby hello.rb"
>
> i've tried that more than once and it says the out is:
>
> "irb(main):001:0> ruby hello.rb
> NameError: undefined local variable or method `hello' for main:Object
> from (irb):1
> irb(main):002:0> "
>
> the guide never said what word processor should i use
> i tried TextEdit.app but it fussed about the .rb
> so i used Microsoft word and this is what it does...
>
> Any tips?
>
> --
> fish can't fly but birds can
> birds can't swim but fish can
>

--
fish can't fly but birds can
birds can't swim but fish can

oh ok
i think i know where i made my mistake
thanks

···

On 4/17/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:

On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:

> On Apr 17, 2007, at 1:22 PM, poison tooth wrote:
>
>> Im just learning ruby and im stuck the guide im using says
>>
>> "Your first program
>> Congratulations! Now that you have made it this far, you are ready to
>> start writing programs.
>> Hello World
>> Grab a text editor and type in the following:
>>
>> puts "Hello World"
>>
>> Save the file as hello.rb and run it by typing
>> ruby hello.rb"
>>
>> i've tried that more than once and it says the out is:
>>
>> "irb(main):001:0> ruby hello.rb
>> NameError: undefined local variable or method `hello' for main:Object
>> from (irb):1
>> irb(main):002:0> "
>>
>> the guide never said what word processor should i use
>> i tried TextEdit.app but it fussed about the .rb
>> so i used Microsoft word and this is what it does...
>>
>> Any tips?
>
> Since you mention TextEdit, I presume you are on a Mac. Also, since
> you mention irb, I presume you are familiar with Terminal. Here is
> an easy way to run a Ruby script in Terminal. After writing your
> hello script in TextEdit save it as hello.rb. Now in terminal at a
> fresh prompt, type "ruby " (without the quotes and remember to
> include the space after "ruby"). Now drag hello.rb into to Terminal
> and hit return. The text "Hello World" should appear.

Also, there is one more possible source of trouble. TextEdit must be
in Plain Text mode when you save a Ruby script. If it's in Rich Text
mode, hit cmnd-shift-T to change the mode before you save.

Regards, Morton

--
fish can't fly but birds can
birds can't swim but fish can

oh
now i got this...

h-68-164-42-185:~ stefan$ ruby ruby.rb
ruby: No such file or directory -- ruby.rb (LoadError)
h-68-164-42-185:~ stefan$ cd documents
h-68-164-42-185:~/documents stefan$ ruby hello.rb
hello.rb:1: Invalid char `\320' in expression
hello.rb:1: Invalid char `\317' in expression
hello.rb:1: Invalid char `\021' in expression
hello.rb:1: Invalid char `\340' in expression
hello.rb:1: Invalid char `\241' in expression
hello.rb:1: Invalid char `\261' in expression
h-68-164-42-185:~/documents stefan$

do i need to get into irb then out and then do it?

···

On 4/17/07, smc smc <fixxie.wits@gmail.com> wrote:

oh ok
i think i know where i made my mistake
thanks
On 4/17/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:
> On Apr 17, 2007, at 2:59 PM, Morton Goldberg wrote:
>
> > On Apr 17, 2007, at 1:22 PM, poison tooth wrote:
> >
> >> Im just learning ruby and im stuck the guide im using says
> >>
> >> "Your first program
> >> Congratulations! Now that you have made it this far, you are ready to
> >> start writing programs.
> >> Hello World
> >> Grab a text editor and type in the following:
> >>
> >> puts "Hello World"
> >>
> >> Save the file as hello.rb and run it by typing
> >> ruby hello.rb"
> >>
> >> i've tried that more than once and it says the out is:
> >>
> >> "irb(main):001:0> ruby hello.rb
> >> NameError: undefined local variable or method `hello' for main:Object
> >> from (irb):1
> >> irb(main):002:0> "
> >>
> >> the guide never said what word processor should i use
> >> i tried TextEdit.app but it fussed about the .rb
> >> so i used Microsoft word and this is what it does...
> >>
> >> Any tips?
> >
> > Since you mention TextEdit, I presume you are on a Mac. Also, since
> > you mention irb, I presume you are familiar with Terminal. Here is
> > an easy way to run a Ruby script in Terminal. After writing your
> > hello script in TextEdit save it as hello.rb. Now in terminal at a
> > fresh prompt, type "ruby " (without the quotes and remember to
> > include the space after "ruby"). Now drag hello.rb into to Terminal
> > and hit return. The text "Hello World" should appear.
>
> Also, there is one more possible source of trouble. TextEdit must be
> in Plain Text mode when you save a Ruby script. If it's in Rich Text
> mode, hit cmnd-shift-T to change the mode before you save.
>
> Regards, Morton
>

--
fish can't fly but birds can
birds can't swim but fish can

--
fish can't fly but birds can
birds can't swim but fish can

smc smc wrote:

oh
now i got this...

h-68-164-42-185:~ stefan$ ruby ruby.rb
ruby: No such file or directory -- ruby.rb (LoadError)
h-68-164-42-185:~ stefan$ cd documents
h-68-164-42-185:~/documents stefan$ ruby hello.rb
hello.rb:1: Invalid char `\320' in expression
hello.rb:1: Invalid char `\317' in expression
hello.rb:1: Invalid char `\021' in expression
hello.rb:1: Invalid char `\340' in expression
hello.rb:1: Invalid char `\241' in expression
hello.rb:1: Invalid char `\261' in expression
h-68-164-42-185:~/documents stefan$

do i need to get into irb then out and then do it?

Firstly:
Q: Why is top posting bad?

Secondly: Save your script as a text file, not as a binary.

···

A: Because it makes it difficult to associate responses.

--
Phillip "CynicalRyan" Gawlowski
http://cynicalryan.110mb.com/
http://clothred.rubyforge.org

Rule of Open-Source Programming #34:

Every successful project will eventually spawn a sub-project

Nope, it looks like the file wasn't saved as plain text. I'm guessing
you tried saving it from Word, like you said earlier. I don't know
how to save as plain text in Word, so I'll show you how to do it
another way.

Open your file in TextEdit. If TextEdit can't open the old file, it
might be having problems with the MS format, just delete the old one
and start a new file in TextEdit, and enter your ruby code. Make sure
you hit return at the end of your file ( this is just so we can view
it with the cat command later ).

Unless you have converted the file to plain text, TextEdit won't let
you save it as a ".rb" file. So, first, go to "Format->Make Plain
Text" (if you only see "Make Rich Text", then it's already plain
text). If it asks you whether to convert the file to plain text,
click OK. Then save the file as "hello.rb". TextEdit will probably
pop up with a message saying 'You have used the extension ".rb" at the
end of the name. The standard extension is ".txt". Click the button
that says "Use .rb". (

Now, you can check from the command line that your file is actually
plain text, by using the "cat" command.

h-68-164-42-185:~/documents stefan$ cat hello.rb
puts "Hello World"

And now you can run it.

h-68-164-42-185:~/documents stefan$ ruby hello.rb
Hello World

Later on, you might want to consider getting a "real" text editor to
help you write ruby code. They'll do things that Word & TextEdit
don't that make it easier to write good code. Features like syntax
highlighting and auto-indentation are two of the ways that "real" text
editors help coders catch errors early on.

I'm not going to tell you which one to use. If you ask any
programmer, anywhere on the web, they'll tell you which they use, and
why it's the one you should use. You might want to check out the
wikipedia article (http://en.wikipedia.org/wiki/Text_editors\), as that
might give you some good leads.

But, I wouldn't get too sidetracked by looking for an editor.
TextEdit (in plain text mode) should be good enough to get you through
the basic tutorials.

···

On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:

oh
now i got this...

h-68-164-42-185:~ stefan$ ruby ruby.rb
ruby: No such file or directory -- ruby.rb (LoadError)
h-68-164-42-185:~ stefan$ cd documents
h-68-164-42-185:~/documents stefan$ ruby hello.rb
hello.rb:1: Invalid char `\320' in expression
hello.rb:1: Invalid char `\317' in expression
hello.rb:1: Invalid char `\021' in expression
hello.rb:1: Invalid char `\340' in expression
hello.rb:1: Invalid char `\241' in expression
hello.rb:1: Invalid char `\261' in expression
h-68-164-42-185:~/documents stefan$

do i need to get into irb then out and then do it?

thanks
i finally got it!!!

···

On 4/17/07, Noah Easterly <noah.easterly@gmail.com> wrote:

On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:
> oh
> now i got this...
>
> h-68-164-42-185:~ stefan$ ruby ruby.rb
> ruby: No such file or directory -- ruby.rb (LoadError)
> h-68-164-42-185:~ stefan$ cd documents
> h-68-164-42-185:~/documents stefan$ ruby hello.rb
> hello.rb:1: Invalid char `\320' in expression
> hello.rb:1: Invalid char `\317' in expression
> hello.rb:1: Invalid char `\021' in expression
> hello.rb:1: Invalid char `\340' in expression
> hello.rb:1: Invalid char `\241' in expression
> hello.rb:1: Invalid char `\261' in expression
> h-68-164-42-185:~/documents stefan$
>
> do i need to get into irb then out and then do it?

Nope, it looks like the file wasn't saved as plain text. I'm guessing
you tried saving it from Word, like you said earlier. I don't know
how to save as plain text in Word, so I'll show you how to do it
another way.

Open your file in TextEdit. If TextEdit can't open the old file, it
might be having problems with the MS format, just delete the old one
and start a new file in TextEdit, and enter your ruby code. Make sure
you hit return at the end of your file ( this is just so we can view
it with the cat command later ).

Unless you have converted the file to plain text, TextEdit won't let
you save it as a ".rb" file. So, first, go to "Format->Make Plain
Text" (if you only see "Make Rich Text", then it's already plain
text). If it asks you whether to convert the file to plain text,
click OK. Then save the file as "hello.rb". TextEdit will probably
pop up with a message saying 'You have used the extension ".rb" at the
end of the name. The standard extension is ".txt". Click the button
that says "Use .rb". (

Now, you can check from the command line that your file is actually
plain text, by using the "cat" command.

h-68-164-42-185:~/documents stefan$ cat hello.rb
puts "Hello World"

And now you can run it.

h-68-164-42-185:~/documents stefan$ ruby hello.rb
Hello World

Later on, you might want to consider getting a "real" text editor to
help you write ruby code. They'll do things that Word & TextEdit
don't that make it easier to write good code. Features like syntax
highlighting and auto-indentation are two of the ways that "real" text
editors help coders catch errors early on.

I'm not going to tell you which one to use. If you ask any
programmer, anywhere on the web, they'll tell you which they use, and
why it's the one you should use. You might want to check out the
wikipedia article (http://en.wikipedia.org/wiki/Text_editors\), as that
might give you some good leads.

But, I wouldn't get too sidetracked by looking for an editor.
TextEdit (in plain text mode) should be good enough to get you through
the basic tutorials.

--
fish can't fly but birds can
birds can't swim but fish can

while you are at it, get the book "learning unix for OS X Tiger"
You're going to need a few unix skills here. Not a lot, but it will help you understand stuff more.
If you need more, get Unix In a Nutshell (it covers OS X, Linux, Unix)

···

On Apr 18, 2007, at 9:40 AM, smc smc wrote:

thanks
i finally got it!!!

On 4/17/07, Noah Easterly <noah.easterly@gmail.com> wrote:

On Apr 17, 6:28 pm, "smc smc" <fixxie.w...@gmail.com> wrote:
> oh
> now i got this...
>
> h-68-164-42-185:~ stefan$ ruby ruby.rb
> ruby: No such file or directory -- ruby.rb (LoadError)
> h-68-164-42-185:~ stefan$ cd documents
> h-68-164-42-185:~/documents stefan$ ruby hello.rb
> hello.rb:1: Invalid char `\320' in expression
> hello.rb:1: Invalid char `\317' in expression
> hello.rb:1: Invalid char `\021' in expression
> hello.rb:1: Invalid char `\340' in expression
> hello.rb:1: Invalid char `\241' in expression
> hello.rb:1: Invalid char `\261' in expression
> h-68-164-42-185:~/documents stefan$
>
> do i need to get into irb then out and then do it?

Nope, it looks like the file wasn't saved as plain text. I'm guessing
you tried saving it from Word, like you said earlier. I don't know
how to save as plain text in Word, so I'll show you how to do it
another way.

Open your file in TextEdit. If TextEdit can't open the old file, it
might be having problems with the MS format, just delete the old one
and start a new file in TextEdit, and enter your ruby code. Make sure
you hit return at the end of your file ( this is just so we can view
it with the cat command later ).

Unless you have converted the file to plain text, TextEdit won't let
you save it as a ".rb" file. So, first, go to "Format->Make Plain
Text" (if you only see "Make Rich Text", then it's already plain
text). If it asks you whether to convert the file to plain text,
click OK. Then save the file as "hello.rb". TextEdit will probably
pop up with a message saying 'You have used the extension ".rb" at the
end of the name. The standard extension is ".txt". Click the button
that says "Use .rb". (

Now, you can check from the command line that your file is actually
plain text, by using the "cat" command.

h-68-164-42-185:~/documents stefan$ cat hello.rb
puts "Hello World"

And now you can run it.

h-68-164-42-185:~/documents stefan$ ruby hello.rb
Hello World

Later on, you might want to consider getting a "real" text editor to
help you write ruby code. They'll do things that Word & TextEdit
don't that make it easier to write good code. Features like syntax
highlighting and auto-indentation are two of the ways that "real" text
editors help coders catch errors early on.

I'm not going to tell you which one to use. If you ask any
programmer, anywhere on the web, they'll tell you which they use, and
why it's the one you should use. You might want to check out the
wikipedia article (http://en.wikipedia.org/wiki/Text_editors\), as that
might give you some good leads.

But, I wouldn't get too sidetracked by looking for an editor.
TextEdit (in plain text mode) should be good enough to get you through
the basic tutorials.

--
fish can't fly but birds can
birds can't swim but fish can

:slight_smile: Congratulations. I hope you have a lot of fun.

···

On 18 Apr 2007, at 01:40, smc smc wrote:

thanks
i finally got it!!!