How to run a .rb file from IRB?

后端 未结 3 1354
执念已碎
执念已碎 2020-12-12 11:37

I am starting out with Ruby on Rails. I am currently going through a tutorial where it says that I have to run a .rb file from IRB and that that will create a .xml file in m

3条回答
  •  孤城傲影
    2020-12-12 11:44

    You can "run" a file in irb by just requiring or loading it.

    $ irb
    >> load './filename.rb'
    

    To change your current working directory within irb, you can use FileUtils:

    >> require 'fileutils'
    >> FileUtils.pwd # prints working directory
    >> FileUtils.cd '/path/to/somewhere' # changes the directory
    

提交回复
热议问题