るりまサーチ (Ruby 2.4.0)

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

Range.new(first, last, exclude_end = false) -> Range (78598.0)

first から last までの範囲オブジェクトを生成して返しま す。

first から last までの範囲オブジェクトを生成して返しま
す。

exclude_end が真ならば終端を含まない範囲オブジェクトを生
成します。exclude_end 省略時には終端を含みます。

@param first 最初のオブジェクト
@param last 最後のオブジェクト
@param exclude_end 真をセットした場合終端を含まない範囲オブジェクトを生成します

@raise ArgumentError first <=> last が nil の場合に発生します

//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(...

Object#to_s -> String (78382.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 #=> Cla...

Thread::Backtrace::Location#to_s -> String (78382.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

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

Thread::Backtrace::Location (24115.0)

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

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の実行結果:

caller_locations.rb:2:in `a'
caller_locations...

Thread::Backtrace::Location#inspect -> String (24109.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//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.inspect
end

# => "path/to/foo.rb:5:in ...

絞り込み条件を変える