るりまサーチ

最速Rubyリファレンスマニュアル検索!
209件ヒット [101-200件を表示] (0.040秒)

別のキーワード

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

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 > >>

Object#to_str -> String (6114.0)

オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...面で代置可能であるような、
* 文字列そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_str
'Edition'
end
end

it = Foo.new
p('Second' + it) #=> "SecondEdition"
//}

@see Object#to_s,Kernel.#String...

Thread#set_trace_func(pr) -> Proc | nil (32.0)

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

...除します。

設定したハンドラを返します。

//emlist[例][ruby]{
th = Thread.new do
class Trace
end
2.to_s
Thread.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]...
...# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>...
..."c-return", "example.rb", 5, :current, #<Binding:0x00007fc8de9673b0>, Thread]
# => ["c-call", "example.rb", 5, :set_trace_func, #<Binding:0x00007fc8de966fc8>, Thread]
//}

@param pr トレースハンドラ(Proc オブジェクト) もしくは nil
@see Thread#add_trace_func Kernel.#set_trace_func...

String#%(args) -> String (26.0)

printf と同じ規則に従って args をフォーマットします。

...printf と同じ規則に従って args をフォーマットします。

args が配列であれば Kernel.#sprintf(self, *args) と同じです。
それ以外の場合は Kernel.#sprintf(self, args) と同じです。

@param args フォーマットする値、もしくはその配列
@retu...
...グ `-' と幅 の指定だけが意味を持ちます。

: 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...

String#hex -> Integer (26.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...# => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

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

このメソッドの逆に数値を文字列に変換するには
Kernel
.#sprintf, String#%,
Integer#to_s
などを使ってください。...

String#oct -> Integer (26.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 (26.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 (26.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 (26.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...

Thread::Backtrace::Location (20.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 アドベントカ...

UnboundMethod#owner -> Class | Module (14.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
//}...

絞り込み条件を変える

<< < 1 2 3 > >>