Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > RubyVM::InstructionSequenceクラス > compile_file

singleton method RubyVM::InstructionSequence.compile_file

compile_file(file, options = nil) -> RubyVM::InstructionSequence[permalink][rdoc]

引数 file で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。

RubyVM::InstructionSequence.compile とは異なり、file、path などのメタデータは自動的に取得します。

[PARAM] file:
ファイル名を文字列で指定します。
[PARAM] options:
コンパイル時のオプションを true、false、Hash オブジェクトのいずれかで指定します。詳細は RubyVM::InstructionSequence.compile_option= を参照してください。
# /tmp/hello.rb
puts "Hello, world!"

# irb
RubyVM::InstructionSequence.compile_file("/tmp/hello.rb")
# => <RubyVM::InstructionSequence:<main>@/tmp/hello.rb>

[SEE_ALSO] RubyVM::InstructionSequence.compile