0
私は実行ファイルをwindowspcでexerbから作成したいこのRubyコードです。 私はhello_world.rbをコンパイルする場合は問題の実行可能ファイルを実行しているがありませんが、このコード Exerbは私の実行可能ファイルを作成しますが、私はそれを実行したときに、私はコードをどのようにRuby Exerb:ファイルクラスがありません
def replace text
replacements = [
{:pattern => /(^ARFD0001\|.*)(FAC_12125)/, :replace_with => '\1FAC_12102'},
{:pattern => /^ARFD0001\|121\|25\|ZIEFAC\|/, :replace_with => 'ARFD0001|121|02|ZIEFAC|'},
{:pattern => /(^ARFD0010\|.*)(12125203)(\d{3})/, :replace_with => '\112102181\3'},
{:pattern => /(^ARFD0010\|.*)(2030341401)/, :replace_with => '\1181701500'},
{:pattern => /(^ARFD0019\|.*)(12125203)(\d{3})/, :replace_with => '\112102181\3'},
{:pattern => /(^ARFD0019\|\d*\|\d*\|\d*)(\|{2})/, :replace_with => '\1|PRINT|'},
{:pattern => /^ARFD0009\|121\|25\|/, :replace_with => 'ARFD0009|121|02|'}
].each{|replacement|text.gsub!(replacement[:pattern], replacement[:replace_with])}
text
end
Dir.glob("*.txt").each{|file|File.write(file, replace(File.read(file)))}
#line above gives the error in Exerb
ここでエラー
undefined method `write' for File:Class (NoMethodError)
を以下の取得とこれを行うには?コードには何も問題はありませんが、Rubyインタプリタではこれが動作しますが、ExecrbにFileクラスを含める必要があるようです。
実際に私は書き込みメソッドが見えません。しかし、どのようにコードは通常のRubyスクリプトで動作しますか?自宅でも試してみました。問題ありませんが、ファイルが書かれています。私は明日の仕事であなたのコードをコンパイルし、どのような違いがあるかを見てみましょう。 – peter
あなたはおそらく異なったルビーバージョンを扱っています、ルビー1.8.7はそれを持っていませんが、ルビ1.9.3はありません – fsainz