以下の内容はhttps://tbpgr.hatenablog.com/entry/20140423/1398258942より取得しました。


Ruby | Integer | to_r

概要

Integer#to_r

詳細

自身を Rational に変換します。

サンプルコード
# encoding: utf-8
require 'tbpgr_utils'

bulk_puts_eval binding, <<-EOS
1.to_r
0.5.to_r
0.to_r
-2.to_r
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils
出力
1.to_r # => (1/1)
0.5.to_r # => (1/2)
0.to_r # => (0/1)
-2.to_r # => (-2/1)



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140423/1398258942より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14