種類
- インスタンスメソッド (66)
- 文書 (22)
ライブラリ
- ビルトイン (55)
クラス
- Module (11)
-
RDoc
:: Options (11) -
Thread
:: Backtrace :: Location (44)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (4) -
absolute
_ path (11) -
base
_ label (11) -
extra
_ accessor _ flags (11) - inspect (11)
-
to
_ s (11) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
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
//}
このメソッドで定義されるメソッ......ドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ accessor(*name) -> nil (18107.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...と書き込みメソッドの両方を
定義します。
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。... -
NEWS for Ruby 3
. 0 . 0 (264.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...", "f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}
* Endless method definition is added. [EXPERIMENTAL]
16746
//emlist{
def square(x) = x * x
//}
* Interpolated String literals are no lo......nger frozen when
`# frozen-string-literal: true` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis]......#private_class_method, toplevel "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#ali... -
RDoc
:: Options # extra _ accessor _ flags -> {String => String} (208.0) -
コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア クセサの種類が値のハッシュを返します。
...コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア
クセサの種類が値のハッシュを返します。
値は r、w、rw のいずれかです。それぞれ attr_reader、attr_writer、
attr_accessor に対応します。... -
NEWS for Ruby 2
. 5 . 0 (108.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......onSequence#trace_points を追加
* String
* String#-@ はフリーズされていない文字列の重複を排除します。
互換性のため、既にフリーズされている文字列には何もしません。 13077
* -"literal" (String#-@) は同じオブジェクトを......3295
* String#casecmp, String#casecmp? に文字列でない引数を与えた場合、TypeErrorを発生させずにnilを返すようにしました
13312
* String#start_with? は正規表現を受け取れるようになりました 13712
* String#delete_prefix, String#delete_pr... -
Thread
:: Backtrace :: Location # absolute _ path -> String (107.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 (107.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_lab... -
Thread
:: Backtrace :: Location # inspect -> String (107.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... -
Thread
:: Backtrace :: Location # to _ s -> String (107.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... -
クラス/メソッドの定義 (12.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ray を明示的に指定しても同じ)
class Foo
def bar
end
end
# 間違ったスーパークラスを指定するとエラー
class Foo < String
end
# => superclass mismatch for class Foo (TypeError)
//}
クラス定義式の中は self がそのクラスであることと、
limitのデ......可能な演算子(例: ==, +, -
など spec/operator を参照)も指定できます(operator参照)。
//emlist[例][ruby]{
class Vector2D
attr_accessor :x, :y # インスタンス変数@x, @yに対応するゲッタとセッタを定義
def initialize(x, y) # コンストラクタ
@x...