IronRubyにも入門してみた

久しぶりに更新
IronRubyはRuby1.8.6をターゲットにMSさんが作ってみたそうで、少し前に1.0が出たところ。
SilverLightや.NETが叩けるらしい。
詳しくは知らない。

注意:IronRubyの基本(入門)が知りたくて、このページに辿り付いた方へ
IronRuby公式サイトのチュートリアルをご覧下さい。
ただし、上記チュートリアルはInternetExplorer8, FireFox3.6.3では上手く動作しませんでした。Safari4, Opera10.53では上手く動作しましたので、同じ様に「動作しないぞ?」となった方はブラウザを変えてお試しください。
以上、注意書きでした。(2010/5/25 記述)

まとめ

  • IronRuby公式からIronRubyインストーラをDLしてきてクリックしていくだけ
    • この際.NET4.0をインストールしていないならば、IronRubyのDownloadの項目から辿れるのでインストールしておく
      • ただし、インストール後、OS再起動が必要となる
  • 一般的なRubyirbコマンドはir
  • 一般的なRubyrubyコマンドはir
インストール作業

IronRuby公式のDownloadからダウンロードしてきて、インストールディレクトリ以外はぽちぽちと押しただけの簡単なお仕事です。


・・・次は何をすればいいの?


コマンドプロンプトでとりあえずirを叩いてみると・・・

To run this appliction, you first must install one of the following versions of the .NET Framework v4.0.30319
Contact your application publisher for instructions about obtaining the appropriate version of the .NET Framework.

HAHA。日本語でOK!!

というわけで、MSから.NETFramework4のインストールを始めてみた。

・・・はて。なぜか、インストールディレクトリの選択もなくインストールが始まった予感。
・・・OSの再起動だと?!MS爆発汁!!



どうもこんばんは。
久しぶりの更新という事でIronRubyにも手をだしてみました。
インストールまではしているので、さっそくコマンドプロンプトからirを叩いてみます。

C:\>ir
IronRuby 1.0.0.0 on .NET 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

>>> 5.times do puts "go to the hell !!" end
go to the hell !!
go to the hell !!
go to the hell !!
go to the hell !!
go to the hell !!
=> 5
>>>exit

ぁ。上手く地獄に逝けそうですね。
ちなみにファイル指定する場合もirなのかもしれませんね。

puts "hello"

上記をカレントディレクトリにhello.rbと保存しておいて

C:\>ir hello.rb
hello

行けてそう。

オマケ

Ruby 2.0 modeだと・・・!?
コマンドプロンプトで「ir /?」と叩くとこんなのが出るんだがどう思う?

C:\>ir /?
Usage: ir.exe [options] [file] [arguments]

Options:
 -Cdirectory              cd to directory, before executing your script
 -d                       set debugging flags (set $DEBUG to true)
 -D                       emit debugging information (PDBs) for Visual Studio de
bugger
 -e 'command'             one line of script. Several -e's allowed. Omit [file]
 -h[elp]                  Display usage
 -Idirectory              specify $LOAD_PATH directory (may be used more than once)
 -Kkcode                  specifies KANJI (Japanese) code-set
 -rlibrary                require the library, before executing your script
 -S                       look for the script using PATH environment variable
 -v                       print version number, then turn on verbose mode
 -w                       turn warnings on for your script
 -W[level]                set warning level; 0=silence, 1=medium (default), 2=verbose
 --version                print the version
 -trace                   enable support for set_trace_func
 -profile                 enable support for 'pi = IronRuby::Clr.profile { block
_to_profile }'
 -1.8.6                   Ruby 1.8.6 mode (default)
 -1.8.7                   Ruby 1.8.7 mode
 -1.9                     Ruby 1.9 mode
 -2.0                     Ruby 2.0 mode
 -X:ExceptionDetail       enable ExceptionDetail mode
 -X:NoAdaptiveCompilation disable adaptive compilation - all code will be compiled
 -X:CompilationThreshold  the number of iterations before the interpreter starts compiling
 -X:PassExceptions        do not catch exceptions that are unhandled by script code
 -X:PrivateBinding        enable binding to private members
 -X:ShowClrExceptions     display CLS Exception information
 -X:RemoteRuntimeChannel  remote console channel

続きは今週中!(こう言っておかないと僕やらないからな。。。)
次はGUIいこう!