294件ヒット
[1-100件を表示]
(0.101秒)
種類
- インスタンスメソッド (234)
- モジュール関数 (24)
- クラス (24)
- 特異メソッド (12)
クラス
- BasicObject (12)
- FalseClass (24)
- Method (24)
- Module (36)
- NilClass (12)
- Object (48)
- Range (12)
- Thread (24)
-
Thread
:: Backtrace :: Location (24) - TrueClass (12)
- UnboundMethod (12)
モジュール
- Enumerable (6)
- Kernel (24)
キーワード
- Location (12)
- Numeric (12)
- String (12)
-
add
_ trace _ func (12) -
define
_ singleton _ method (24) - inspect (48)
-
method
_ missing (12) - name (12)
- new (12)
- owner (12)
-
set
_ trace _ func (24) -
to
_ set (6) -
to
_ str (12)
検索結果
先頭5件
-
NilClass
# to _ s -> String (21115.0) -
空文字列 "" を返します。
...空文字列 "" を返します。
//emlist[例][ruby]{
nil.to_s # => ""
//}... -
TrueClass
# to _ s -> String (21115.0) -
常に文字列 "true" を返します。
...常に文字列 "true" を返します。
//emlist[例][ruby]{
true.to_s # => "true"
//}... -
Object
# to _ s -> String (18139.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... -
Thread
:: Backtrace :: Location # to _ s -> String (18121.0) -
self が表すフレームを 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/to/foo.rb:5:in `initialize'
# path/to/foo.rb... -
FalseClass
# to _ s -> String (18115.0) -
常に文字列 "false" を返します。
...常に文字列 "false" を返します。
//emlist[例][ruby]{
false.to_s # => "false"
//}... -
Method
# to _ s -> String (15145.0) -
self を読みやすい文字列として返します。
...ッドを定義しているクラス/モジュール名、
method は、メソッド名を表します。
//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)......ブジェクトになります。
//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo)......# => #<Method: Foo.foo>
# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar.foo>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: Object(Baz)#baz>......:2」は Method#source_location を表します。
source_location が nil の場合には付きません。
//emlist[例][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.......ェクトになります。
//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo)......Foo.foo() foo.rb:11>
# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: Stri... -
Module
# to _ s -> String (15145.0) -
モジュールやクラスの名前を文字列で返します。
...//emlist[例][ruby]{
module A
module B
end
p B.name #=> "A::B"
class 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:0x0......0007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}... -
Enumerable
# to _ set(klass = Set , *args) -> Set (6120.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...作ることができます
(ここでいう集合クラスとは、Setとメソッド/クラスメソッドで互換性のあるクラスです。
Ruby 2.7 以前は SortedSet が定義されていました)。
引数 args およびブロックは、集合オブジェクトを生成するための......ます。
@return 生成された集合オブジェクトを返します。
//emlist[][ruby]{
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
Enumerable
# to _ set(klass = Set , *args) {|o| . . . } -> Set (6120.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...作ることができます
(ここでいう集合クラスとは、Setとメソッド/クラスメソッドで互換性のあるクラスです。
Ruby 2.7 以前は SortedSet が定義されていました)。
引数 args およびブロックは、集合オブジェクトを生成するための......ます。
@return 生成された集合オブジェクトを返します。
//emlist[][ruby]{
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
Object
# to _ str -> String (6120.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...