As others have pointed out, running ruby hello.rb
does run the script; there is no compilation involved (except behind the scenes in the Ruby virtual machine, but you don't need to concern yourself with that).
Based on the code of the file which you gave in a comment (I've put in line breaks and indentation):
class Hello
def say
puts "hello World"
end
end
... the reason your script doesn't seem to do anything is that it only defines a class and a method but doesn't instantiate the class or call the method. You had the right idea (in another comment) to call h = Hello.new()
; after that you can put h.say
and it will say "hello World".
(Parentheses are usually not required, including in these two method calls; but sometimes they are important. There are varying conventions, but most Rubyists skip them when calling methods without any arguments, like new
and say
here.)
EDIT:
rails c
is for Ruby on Rails, which is a separate entity from the Ruby language (although it's written in Ruby).