るりまサーチ

最速Rubyリファレンスマニュアル検索!
101件ヒット [1-100件を表示] (0.025秒)
トップページ > クエリ:tr[x] > クエリ:attr_accessor[x]

別のキーワード

  1. module attr
  2. net/imap attr
  3. _builtin attr
  4. rdoc attr_modifiers
  5. etc sc_thread_attr_stacksize

ライブラリ

検索結果

<< 1 2 > >>

Module#attr_accessor(*name) -> [Symbol] (24213.0)

インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。

...ッドと書き込みメソッドの両方を
定義します。

//emlist[例][ruby]{
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 (24201.0)

インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。

...と書き込みメソッドの両方を
定義します。


このメソッドで定義されるメソッドの定義は以下の通りです。

//emlist[例][ruby]{
def name
@name
end
def name=(val)
@name = val
end
//}

@param name String または Symbol を 1 つ以上指定します。...

static VALUE rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) (12200.0)

RDoc::Options#extra_accessor_flags -> {String => String} (6306.0)

コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア クセサの種類が値のハッシュを返します。

...コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア
クセサの種類が値のハッシュを返します。

値は r、w、rw のいずれかです。それぞれ attr_reader、attr_writer、
attr_accessor
に対応します。...

Thread::Backtrace::Location#absolute_path -> String (3106.0)

self が表すフレームの絶対パスを返します。

...][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#path...

絞り込み条件を変える

Thread::Backtrace::Location#base_label -> String (3106.0)

self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。

...が表すフレームの基本ラベルを返します。通常、
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 (3106.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).loc...

Thread::Backtrace::Location#to_s -> String (3106.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...

Thread::Backtrace::Location (3006.0)

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

...果:

caller_locations.rb:2:in `a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'

//emlist[例2][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...
...//}

例2の実行結果:

init.rb:4:in `initialize'
init.rb:8:in `new'
init.rb:8:in `<main>'

=== 参考

* Ruby VM アドベントカレンダー #4 vm_backtrace.c: https://www.atdot.net/~ko1/diary/201212.html#d4...

NEWS for Ruby 3.0.0 (18.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...リンク先を参照してください。

== 言語仕様の変更

* Keyword arguments are now separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argu...
...redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in` is changed to return `true` or `false`. 17371

//emlist{
0 => a
p a #=> 0

{b: 0, c: 1} => {b:}
p b #=> 0
//}

//emlist{
# version 3.0
0 in 1 #=> false

# version 2.7
0 in 1...
...vel "private" and "public" methods now accept single array argument with a list of method names. 17314
* Module#attr_accessor, Module#attr_reader, Module#attr_writer and Module#attr methods now return an array of defined method names as symbols. 17314
* Module#alias_method now returns the de...

絞り込み条件を変える

<< 1 2 > >>