Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Rationalクラス
クラスの継承リスト: Rational < Numeric < Comparable < Object < Kernel < BasicObject
有理数を扱うクラスです。
「1/3」のような有理数を扱う事ができます。Integer や Float と同様に Rational.new ではなく、 Kernel.#Rational を使用して Rational オブジェクトを作成します。
例:
Rational(1, 3) # => (1/3) Rational('1/3') # => (1/3) Rational('0.33') # => (33/100) Rational.new(1, 3) # => NoMethodError
ただし、1.8系とは異なり、Rational オブジェクトは常に既約(それ以上 約分できない状態)である事に注意してください。
Rational(2, 6) # => (1/3) Rational(1, 3) * 3 # => (1/1)
定義 | 説明 | |
---|---|---|
convert(*arg) -> Rational
|
引数を有理数(Rational)に変換した結果を返します。 |
!
!=
+@
-@
abs
clone
div
divmod
eql?
i
integer?
modulo
nonzero?
real?
remainder
step
to_int
zero?
===
=~
__id__
__send__
_dump
class
dclone
display
enum_for
equal?
extend
freeze
frozen?
initialize
initialize_copy
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
method
method_missing
methods
must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
respond_to_missing?
singleton_class
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_io
to_proc
to_regexp
to_str
to_yaml
to_yaml_properties
to_yaml_style
trust
untaint
untrust
untrusted?
wont_be
wont_be_close_to
wont_be_empty
wont_be_instance_of
wont_be_kind_of
wont_be_nil
wont_be_same_as
wont_be_within_epsilon
wont_equal
wont_include
wont_match
wont_respond_to
.new
定義 | 説明 | ライブラリ |
---|---|---|
to_d(nFig = 0) -> BigDecimal
|
自身を BigDecimal に変換します。 |
bigdecimal/util |