るりまサーチ

最速Rubyリファレンスマニュアル検索!
322件ヒット [1-100件を表示] (0.102秒)
トップページ > クエリ:-[x] > クエリ:ruby[x] > クエリ:abs[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#abs -> Integer (18237.0)

self の絶対値を返します。

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

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

Complex#abs -> Numeric (18231.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...

Numeric#abs -> Numeric (18231.0)

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

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

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

Float#abs -> Float (18225.0)

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

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

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

BigDecimal#abs -> BigDecimal (18219.0)

self の絶対値を返します。

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

//emlist[][ruby]{
require 'bigdecimal'
BigDecimal('5').abs.to_i # => 5
BigDecimal('-3').abs.to_i # => 3
//}...

絞り込み条件を変える

Rational#abs -> Rational (18219.0)

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

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

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

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

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

...= 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 = Ruby...
...VM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::InstructionSequence#path...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (6396.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...文字列を抽象構文木にパースし、その木の根ノードを返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコ...
... Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9...
...2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant: true)
# => (SCOPE@1:0-1:15
# tbl: [:x, :y]
# args: nil
# body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))))
//}...

RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (6396.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...文字列を抽象構文木にパースし、その木の根ノードを返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコ...
... Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9...
...2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant: true)
# => (SCOPE@1:0-1:15
# tbl: [:x, :y]
# args: nil
# body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))))
//}...

RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (6366.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree...
...@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
# block: nil)
# body:
# (FCALL@6:2-6:2...
...1 :puts (LIST@6:7-6:21 (STR@6:7-6:21 "hello, world") nil)))
//}...

絞り込み条件を変える

RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (6366.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree...
...@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: nil
# kw: nil
# kwrest: nil
# block: nil)
# body:
# (FCALL@6:2-6:2...
...1 :puts (LIST@6:7-6:21 (STR@6:7-6:21 "hello, world") nil)))
//}...

RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node (6360.0)

pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。

...字列が Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
#...
...(COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
# :parse_file (LIST@1:41-1:49 (STR@1:41-1:49 "") nil)) nil)))
//}...

RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (6360.0)

pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。

...字列が Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
#...
...(COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
# :parse_file (LIST@1:41-1:49 (STR@1:41-1:49 "") nil)) nil)))
//}...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (6354.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...m string パースする対象の Ruby のコードを文字列で指定します。
@raise SyntaxError string が Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args:...
...nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
//}...

Numeric#abs2 -> Numeric (6243.0)

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

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


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

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

絞り込み条件を変える

<< 1 2 3 ... > >>