66件ヒット
[1-66件を表示]
(0.047秒)
クラス
- Module (11)
- Object (11)
-
Thread
:: Backtrace :: Location (44)
キーワード
-
absolute
_ path (11) -
base
_ label (11) -
initialize
_ copy (11) - inspect (11)
-
to
_ s (11)
検索結果
先頭5件
-
Module
# attr _ accessor(*name) -> [Symbol] (18140.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...]{
class User
attr_accessor :name # => [:name, :name=]
# 複数の名前を渡すこともできる
attr_accessor :id, :age # => [:id, :id=, :age, :age=]
end
//}
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
def......name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ accessor(*name) -> nil (18122.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...と書き込みメソッドの両方を
定義します。
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。... -
Object
# initialize _ copy(obj) -> object (33.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...う名前のメソッドは
自動的に private に設定されます。
@raise TypeError レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#clone,Object#dup
以下に例として、dup や clone がこの......を作ります。 obj.clone は、さらに
特異メソッドのコピーも行います。
//emlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "sing.........>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# tainted?: true
# singleton methods: :bar
/......を作ります。 obj.clone は、さらに
特異メソッドのコピーも行います。
//emlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.......4>
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# singleton methods: :bar
//}... -
Thread
:: Backtrace :: Location # absolute _ path -> String (21.0) -
self が表すフレームの絶対パスを返します。
...st[例][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.absolute_path
end
# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}
@see Thread::Backtrace::Location#p... -
Thread
:: Backtrace :: Location # base _ label -> String (21.0) -
self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。
...されます。
//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.base_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Location#label... -
Thread
:: Backtrace :: Location # inspect -> String (15.0) -
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/f... -
Thread
:: Backtrace :: Location # to _ s -> String (15.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/to/foo....