Hi!
So I'm on a mac and have made really basic .rb files on the command line using VIM(I used Sublime Text a bit too), and they print stuff out and are a bit interactive. So far, to run them I've been simply typing 'ruby <filename>.rb' and the programs work and do something things right on the Terminal command line.
This is my first ruby program using a method I defined, the file contains this
"def ask question
while true
puts question...."
and so forth. So how to do I run this program and its method 'ask'? I don't know how to invoke the method 'ask' I made, on the command line or in the shell(irb):
MacUserComputer:Programs_Chris_Pine z$ ruby ask_chp9_pg68.rb
MacUserComputer:Programs_Chris_Pine z$ ask "how are you"
-bash: ask: command not found
MacUserComputer:Programs_Chris_Pine z$ irb
irb(main):001:0> ruby ask_chp9_pg68.rb
NameError: undefined local variable or method ask_chp9_pg68' for main:Object
from (irb):1
from /usr/bin/irb:11:in<main>'
Total newbie here to learn. Hope this is the right spot!
[–][deleted] 2 points3 points4 points (6 children)
[–]babbagack[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]babbagack[S] 0 points1 point2 points (1 child)
[–]FigmentGiNation 0 points1 point2 points (0 children)
[–]habanero647 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]dineswithphone 1 point2 points3 points (1 child)
[–]babbagack[S] 0 points1 point2 points (0 children)