194件ヒット
[1-100件を表示]
(0.275秒)
クラス
- BasicObject (11)
- Data (4)
- Method (22)
- Module (33)
- Object (22)
- Proc (22)
- Struct (22)
- Thread (36)
-
Thread
:: Backtrace :: Location (22)
キーワード
-
add
_ trace _ func (11) - inspect (64)
-
method
_ missing (11) - name (11)
-
set
_ trace _ func (11) -
to
_ str (11)
検索結果
先頭5件
-
Thread
:: Backtrace :: Location # to _ s -> String (26122.0) -
self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。
...mlist[例][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/to/foo.rb:5:in `initialize'
# path/to/foo.rb:9:in `new'
# path/to/foo.rb:9:in `<main>'
//}... -
Object
# to _ s -> String (26116.0) -
オブジェクトの文字列表現を返します。
...使って文字列に変換し
ます。
//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... -
Module
# to _ s -> String (23140.0) -
モジュールやクラスの名前を文字列で返します。
...lass C
end
end
p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"
# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}... -
Struct
# to _ s -> String (23122.0) -
self の内容を人間に読みやすい文字列にして返します。
...スに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<s... -
Method
# to _ s -> String (23116.0) -
self を読みやすい文字列として返します。
...。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass1 と klass2 が同じ場合は以下の形式になります。......st[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}
klass1 と klass2 が同じ場合は以下の... -
Proc
# to _ s -> String (23116.0) -
self の文字列表現を返します。
...self の文字列表現を返します。
可能なら self を生成したソースファイル名、行番号を含みます。
//emlist[例][ruby]{
p Proc.new {
true
}.to_s
# => "#<Proc:0x0x401a880c@-:3>"
//}... -
Data
# to _ s -> String (23110.0) -
self の内容を人間に読みやすい文字列にして返します。
...容を人間に読みやすい文字列にして返します。
//emlist[例][ruby]{
Customer = Data.define(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<data Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"
//}... -
Thread
# to _ s -> String (23110.0) -
自身を人間が読める形式に変換した文字列を返します。
...自身を人間が読める形式に変換した文字列を返します。
//emlist[例][ruby]{
a = Thread.current
a.inspect # => "#<Thread:0x00007fdbaf07ddb0 run>"
b = Thread.new{}
b.inspect # => "#<Thread:0x00007fdbaf8f7d10@(irb):3 dead>"
//}... -
Object
# to _ str -> String (14115.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... -
Module
# inspect -> String (8040.0) -
モジュールやクラスの名前を文字列で返します。
...lass C
end
end
p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"
# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}... -
Module
# name -> String | nil (8040.0) -
モジュールやクラスの名前を文字列で返します。
...lass C
end
end
p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"
# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}...