LoginSignup
1
2

More than 5 years have passed since last update.

Opal gem内のRubyライブラリのみをJavaScriptに変換する

Posted at

gem install opalでインストールされるOpalのgemには、Opal独自のライブラリや、Rubyの標準ライブラリ(の機能限定版)をOpalに移植したものがRubyスクリプトの形で同梱されています。

opalコマンドの-Lオプションを使うと、これらのライブラリをJavaScriptに変換したものが出力できます。

Dateクラスを定義するdateライブラリのJS版をdate.jsというファイルに保存するには、以下のようにします。

$ opal -L -r date > date.js

また、Opal独自のライブラリ、nativeライブラリのJS版をnative.jsにするには以下のようにします。

$ opal -L -r native > native.js
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2