るりまサーチ

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

別のキーワード

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

検索結果

<< 1 2 3 > >>

Complex#abs -> Numeric (29227.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 (29221.0)

self の絶対値を返します。

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

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

Numeric#abs -> Numeric (29221.0)

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

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

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

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

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

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

相対パスの場合はカレントディレクトリを基準とします。
dir_string を渡した場合はそのディレクトリを基準とします。

File.expand_path と異なり、 file_name 先頭が "~" である場...
...//emlist[例][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 (20302.0)

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

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

@param file_name ファイル名を表す文字列を指定します。文字列でない場合は、to_path メソッド、to_str メソッドの順で暗黙の型変換が試みられます。

@raise TypeErr...
...//emlist[例][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 (20202.0)

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

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

self を文字列から作成していた場合は nil を返します。

例1:irb で実行した場合

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

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

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

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

@see RubyVM::Ins...
...tructionSequence#path...

Thread::Backtrace::Location#absolute_path -> String (20202.0)

self が表すフレームの絶対パスを返します。

...self が表すフレームの絶対パスを返します。

//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
e
nd
e
nd

Foo.new(0..2).locations.map do |call|
puts call.absolute_path
e
nd

# => /path/to/foo.rb
# /path...
.../to/foo.rb
# /path/to/foo.rb
//}

@see Thread::Backtrace::Location#path...

RubyVM::AbstractSyntaxTree (20002.0)

Ruby のコードをパースして得られる抽象構文木を扱うモジュールです。

...Ruby のコードをパースして得られる抽象構文木を扱うモジュールです。

抽象構文木はRubyVM::AbstractSyntaxTree::Nodeクラスのインスタンスとして表されます。


このモジュールはMRIの抽象構文木の実装の詳細を表します。

このモ...
...し安定したAPIやMRI以外の実装で抽象構文木を扱いたい場合、
parser gem (https://github.com/whitequark/parser)や
Ripperの使用を検討してください。
もし RubyVM::AbstractSyntaxTree のAPIを安定にしたい場合、14844 での議論に参加してください。...

Complex#abs2 -> Numeric (17227.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 (17227.0)

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

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


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

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

絞り込み条件を変える

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

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

...ます。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を指定すると、 Node#token が利用できます。
@param error_tolerant true を指定する...
...ー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
@raise SyntaxError string が Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tb...
...) :+ (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)))...
<< 1 2 3 > >>