るりまサーチ

最速Rubyリファレンスマニュアル検索!
287件ヒット [1-100件を表示] (0.234秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

検索結果

<< 1 2 3 > >>

Complex#abs -> Numeric (32225.0)

自身の絶対値を返します。

...す。

以下の計算の結果を Float オブジェクトで返します。

sqrt(self.real ** 2 + self.imag ** 2)

//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
//}

@see Complex#abs2...

Integer#abs -> Integer (32219.0)

self の絶対値を返します。

...self の絶対値を返します。

//emlist[][ruby]{
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321
//}...

Numeric#abs -> Numeric (32219.0)

自身の絶対値を返します。

...自身の絶対値を返します。

//emlist[例][ruby]{
12.abs #=> 12
(-34.56).abs #=> 34.56
-34.56.abs #=> 34.56
//}...

Float#abs -> Float (32213.0)

自身の絶対値を返します。

...自身の絶対値を返します。

//emlist[例][ruby]{
34.56.abs # => 34.56
-34.56.abs # => 34.56
//}...

Rational#abs -> Rational (32213.0)

自身の絶対値を返します。

...自身の絶対値を返します。

//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}...

絞り込み条件を変える

Bignum#abs -> Fixnum | Bignum (32201.0)

self の絶対値を返します。

self の絶対値を返します。

Fixnum#abs -> Fixnum | Bignum (32201.0)

self の絶対値を返します。

self の絶対値を返します。

Complex#abs2 -> Numeric (20225.0)

自身の絶対値の 2 乗を返します。

...自身の絶対値の 2 乗を返します。

以下の計算の結果を返します。

self.real ** 2 + self.imag ** 2

//emlist[例][ruby]{
Complex(1, 1).abs2 # => 2
Complex(1.0, 1.0).abs2 # => 2.0
Complex('1/2', '1/2').abs2 # => (1/2)
//}

@see Complex#abs...

Numeric#abs2 -> Numeric (20225.0)

自身の絶対値の 2 乗を返します。

...自身の絶対値の 2 乗を返します。


//emlist[例][ruby]{
2.abs2 # => 4
-2.abs2 # => 4
2.0.abs2 # => 4
-2.0.abs2 # => 4
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。...

File.absolute_path(file_name, dir_string=nil) -> String (20200.0)

file_name を絶対パスに変換した文字列を返します。

...例][ruby]{
p Dir.getwd #=> "/home/matz/work/bar"
p ENV["HOME"] #=> "/home/matz"
p File.absolute_path("..") #=> "/home/matz/work"
p File.absolute_path("..", "/tmp") #=> "/"
p File.absolute_path("~") #=> "/home/matz/work/bar/~"
p File.absolute_...
...path("~foo") #=> "/home/matz/work/bar/~foo"
//}

@see File.expand_path...

絞り込み条件を変える

File.absolute_path?(file_name) -> bool (20200.0)

file_name が絶対パスなら true を、そうでなければ false を返します。

...[ruby]{
File.absolute_path?("//foo/bar\\baz") # => true
File.absolute_path?("C:foo\\bar") # => false
File.absolute_path?("~") # => false

# プラットフォームが cygwin、mswin、mingw の場合
File.absolute_path?("C:\\foo\\bar") # => true
File.absolute_path?("/foo/bar\\baz...
...") # => false

# プラットフォームが上記以外の場合
File.absolute_path?("C:\\foo\\bar") # => false
File.absolute_path?("/foo/bar\\baz") # => true
//}...

RubyVM::InstructionSequence#absolute_path -> String | nil (20200.0)

self が表す命令シーケンスの絶対パスを返します。

...ます。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello...
...puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::InstructionSequence#path...
<< 1 2 3 > >>