るりまサーチ

最速Rubyリファレンスマニュアル検索!
302件ヒット [201-300件を表示] (0.057秒)

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 > >>

String#oct -> Integer (24.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2

p "1_0_1x".oct # => 65
//}

@see String#hex, String#to_i, String#to_f,
Kernel
.#Integer, Kernel.#Float

逆に、数値を文字列に変換するにはKernel.#sprintf,
String#%, Integer#to_s を使用します。...

String#to_f -> Float (24.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...# => Infinity
# warning: Float 10101010101010101010... out of range
//}

なお、このメソッドとは逆に、数値を文字列に変換するには
Kernel
.#sprintf, String#%, Integer#to_s
を使用します。

@see String#hex, String#oct, String#to_i,
Kernel
.#Integer, Kernel.#Float...

String#to_i(base = 10) -> Integer (24.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...する整数。0 か、2〜36 の整数。
@return 整数

このメソッドの逆に数値を文字列に変換するには、
Kernel
.#sprintf, String#%, Integer#to_s
を使用します。

String#hex, String#oct, String#to_f,
Kernel
.#Integer, Kernel.#Float
も参照してください。...

Thread#add_trace_func(pr) -> Proc (24.0)

スレッドにトレース用ハンドラを追加します。

...を返します。

@param pr トレースハンドラ(Proc オブジェクト)

//emlist[例][ruby]{
th = Thread.new do
class Trace
end
43.to_s
end
th.add_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "exampl...
...e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => ["c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}

@see Thread#set_trace_func Kernel.#set_trace_func...

bigdecimal (24.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...) #=> Infinity
BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
//}

無限大を表す BigDecimal オブジェクトを作成する場合、
Kernel
.#BigDecimal の引数に "Infinity" や "-Infinity" を指定して
ください。(大文字小文字を区別します)

//emlist[][ruby]{
requ...
...ruby]{
require "bigdecimal"
BigDecimal("0.0") / BigDecimal("0.0") # => NaN
//}

NaN を表す BigDecimal オブジェクトを作成する場合、
Kernel
.#BigDecimal の引数に "NaN" を指定してください。(大文字小文
字を区別します)

//emlist[][ruby]{
require "bigdecimal"
BigD...
...2").div(3, 12).to_s(10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}

: truncate, round, ceil, floor

これらのメソッドは小数点からの相対位置を指定して桁数を決定します。

//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("6.66666666666666").round(12).to_s(10)
# => 0.666...

絞り込み条件を変える

Thread::Backtrace::Location (18.0)

Ruby のフレームを表すクラスです。

...ームを表すクラスです。

Kernel
.#caller_locations から生成されます。

//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end

c(0..2).map do |call|
puts call.to_s
end
//}

例1の実行結果:

c...
...ttr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}

例2の実行結果:

init.rb:4:in `initialize'
init.rb:8:in `new'
init.rb:8:in `<main>'

=== 参考

* Ruby VM アドベントカ...

tracer (18.0)

実行トレース出力をとる機能を提供します。

...ス出力をとる機能を提供します。

使い方は大きく分けて2通り。

ひとつは以下のようにコマンドラインから Kernel.#require する方法です。
hoge.rb の実行をすべてトレース出力します。

ruby -rtracer hoge.rb

もうひとつはソース...
...class Hoge
def Hoge.fuga(i)
"fuga #{i}"
end
end

Tracer.add_filter {|event, file, line, id, binding, klass|
event =~ /line/ and klass.to_s =~ /hoge/i
}
Tracer.on
for i in 0..3
puts Hoge.fuga(i) if i % 3 == 0
end
Tracer.off

=== SEE ALSO

Kernel
.#set_trace_func...

UnboundMethod#owner -> Class | Module (12.0)

このメソッドが定義されている class か module を返します。

...このメソッドが定義されている class か module を返します。

//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}...

ruby 1.6 feature (12.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...def initialize(obj) @obj = obj end
def []=() @obj = obj end
def []() @obj end
end
module Kernel
def _ptr() Ptr.new(self) end
end

def foo(int)
int[] += 1
end
x = 1._ptr...
...まり、名前解
決中にThreadが切替え可能ということです)

require 'resolv'
p Resolv.new.getaddress("www.ruby-lang.org").to_s

=> /usr/local/lib/ruby/1.6/resolv.rb:160: warning: timeout (...) interpreted as method call
/usr/local/lib/ruby/1.6/resolv.rb:55: warni...

sprintf フォーマット (12.0)

sprintf フォーマット === sprintf フォーマット

...グ `-' と幅 の指定だけが意味を持ちます。

: s

文字列を出力します。

引数が String オブジェクトでなければ to_s メソッドにより文字列化
したものを引数として扱います。

: p

Object#inspect の結果を出力します。
//emlist[][r...
...tf("%p", /e+/) #=> "/e+/"
//}


: d
: i

引数の数値を10進表現の整数として出力します。

引数が整数でなければ関数 Kernel.#Integer と同じ規則で整数に
変換されます。

//emlist[][ruby]{
p sprintf("%d", -1) #=> "-1"
p sprintf("%d", 3.1) #=> "3"
p sprint...

絞り込み条件を変える

<< < 1 2 3 4 > >>