Reputation: 8461
I have a program in a file called project1.rb
. Inside this file I have a method called check_num(n)
. I simply want to call that method from the command line or IRB, but I can't figure out how and can't seem to find docs explaining how.
Here is what I've tried:
$ ruby project1.rb check_num(100)
#=> -bash: syntax error near unexpected token `('
Can Anyone help me out with this?
Upvotes: 1
Views: 1322
Reputation: 198294
ruby -r ./project1.rb -e "check_num(100)"
-r filename
is same as Ruby require "filename"
; and -e code
evaluates Ruby code.
Upvotes: 5