るりまサーチ

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

別のキーワード

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

検索結果

<< 1 2 > >>

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

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

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

//emlist[例][ruby]{
class
User
attr_accessor
:name # => [:name, :name=]
# 複数の名前を渡すこともできる
attr_accessor
:id, :age # => [:id, :id=, :age, :age=]
end
//}

このメソッドで定義されるメ...

クラス/メソッドの定義 (246.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined

===[a:class] クラス定義

//emlist[例][ruby]{
class
Foo < S...
...uper
def test
# ...
end
# ...
end
//}

文法:

class
識別子 [`<' superclass ]
式..
end

文法:

class
識別子 [`<' superclass ]
式..
[rescue [error_type,..] [=> evar] [then]
式..]..
[else...
...再定義可能な演算子(例: ==, +, -
など spec/operator を参照)も指定できます(operator参照)。

//emlist[例][ruby]{
class
Vector2D
attr_accessor
:x, :y # インスタンス変数@x, @yに対応するゲッタとセッタを定義
def initialize(x, y) # コンストラク...

NEWS for Ruby 3.0.0 (96.0)

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

...d in singleton class definitions in methods is now a SyntaxError
instead of a warning. yield in a class definition outside of a method
is now a SyntaxError instead of a LocalJumpError. 15575
* When a class variable is overtaken by the same definition in an
ancestor class/module, a Run...
...timeError is now raised (previously,
it only issued a warning in verbose mode). Additionally, accessing a
class
variable from the toplevel scope is now a RuntimeError.
14541
* Assigning to a numbered parameter is now a SyntaxError instead of
a warning.

== Command line options

==...
...nd classes included or prepended the receiver. 9573
* Module#public, Module#protected, Module#private, Module#public_class_method, Module#private_class_method, toplevel "private" and "public" methods now accept single array argument with a list of method names. 17314
* Module#attr_accessor,...

JSON::Parser.new(source, options => {}) -> JSON::Parser (42.0)

パーサを初期化します。

...っても付加情報を生成しません。デフォルトは真です。
: :object_class
JSON のオブジェクトを変換するクラスを指定します。デフォルトは Hash です。
: :array_class
JSON の配列を変換するクラスを指定します。デフォルトは Array...
...//emlist[例 object_class を指定する][ruby]{
require 'json'

class
Person
attr_accessor
:name, :age

def []=(key, value)
instance_variable_set("@#{key}", value)
end
end

parser = JSON::Parser.new(DATA.read, object_class: Person)
person = parser.parse
person.class # => Person
person.n...

JSON::Parser#parse -> object (24.0)

現在のソースをパースして結果を Ruby のオブジェクトとして返します。

...す。

//emlist[例][ruby]{
require 'json'

class
Person
attr_accessor
:name, :age

def []=(key, value)
instance_variable_set("@#{key}", value)
end
end

parser = JSON::Parser.new(DATA.read, object_class: Person)
person = parser.parse
person.class # => Person
person.name # => "tanaka"
per...

絞り込み条件を変える

Object#initialize_copy(obj) -> object (18.0)

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

...るかを示します。

obj.dup は、新たに生成したオブジェクトに対して
initialize_copy を呼び

//emlist[][ruby]{
obj2 = obj.class.allocate
obj2.initialize_copy(obj)
//}

obj2 に対してさらに obj の汚染状態、インスタンス変数、ファイナライザを
...
...複製を作ります。 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...
...j.class.allocate
obj2.initialize_copy(obj)
//}

obj2 に対してさらに obj のインスタンス変数、ファイナライザを
コピーすることで複製を作ります。 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.bar
rescue NameError
p $!
end
end

obj.foo = 1

check Object.new.send(:initialize_copy, obj)
#=> instance variables: #<O...

NEWS for Ruby 2.5.0 (12.0)

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

...12882

* Method
* Method#=== は Proc#===と同じようにMethod#callを呼び出します 14142

* Module
* Module#attr, Module#attr_accessor, Module#attr_reader, Module#attr_writer はパブリックメソッドになりました 14132
* Module#define_method, Module#alias_method...
...の場合:
//emlist{
{ (method key) => (counter) }
//}
* メソッドキーにはフォーマットがあります:
//emlist{
[class, method-name, start lineno, start column, end lineno, end column]
//}
* 例えば [Object, :foo, 1, 0, 7, 3] は Object#foo は1行目の0桁...

Thread::Backtrace::Location (12.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...

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

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

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

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

# => /path/to/foo.rb
# /path...

Thread::Backtrace::Location#base_label -> String (12.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.ba...

絞り込み条件を変える

<< 1 2 > >>