121件ヒット
[1-100件を表示]
(0.057秒)
クラス
- Object (22)
- String (55)
- Thread (22)
-
Thread
:: Backtrace :: Location (11) - UnboundMethod (11)
キーワード
- % (11)
-
add
_ trace _ func (11) - hex (11)
- oct (11)
- owner (11)
-
set
_ trace _ func (11) -
to
_ f (11) -
to
_ i (11) -
to
_ str (11)
検索結果
先頭5件
-
Object
# to _ s -> String (18128.0) -
オブジェクトの文字列表現を返します。
...オブジェクトの文字列表現を返します。
Kernel.#print や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。
//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it......= Foo.new(40)
puts it #=> #<Foo:0x2b69110>
class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end
puts it #=> Class:Foo Number:40
//}
@see Object#to_str,Kernel.#String... -
Thread
:: Backtrace :: Location # to _ s -> String (18126.0) -
self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。
...すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
# => path/t... -
Object
# to _ str -> String (6115.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 (33.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 (27.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 (27.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 (27.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 (27.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 (27.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 (27.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...