種類
- インスタンスメソッド (77)
- 文書 (22)
- ライブラリ (11)
- 特異メソッド (11)
クラス
-
JSON
:: Parser (22) - 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)
- new (11)
- parse (11)
-
rdoc
/ parser / ruby (11) -
to
_ s (11) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Module
# attr _ accessor(*name) -> [Symbol] (24313.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
.../emlist[例][ruby]{
class User
attr_accessor :name # => [:name, :name=]
# 複数の名前を渡すこともできる
attr_accessor :id, :age # => [:id, :id=, :age, :age=]
end
//}
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def nam......e
@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ accessor(*name) -> nil (24301.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...と書き込みメソッドの両方を
定義します。
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。... -
JSON
:: Parser # parse -> object (9206.0) -
現在のソースをパースして結果を Ruby のオブジェクトとして返します。
...を 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"
person.age # => 20
__END__
{
"name":"tanaka",
"age":20
}
//}
@see JSON::Parser#source... -
RDoc
:: Options # extra _ accessor _ flags -> {String => String} (6212.0) -
コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア クセサの種類が値のハッシュを返します。
...コマンドライン引数の --accessor オプションで指定したアクセサがキー、ア
クセサの種類が値のハッシュを返します。
値は r、w、rw のいずれかです。それぞれ attr_reader、attr_writer、
attr_accessor に対応します。... -
rdoc
/ parser / ruby (6036.0) -
Ruby のソースコードを解析するためのサブライブラリです。
...Ruby のソースコードを解析するためのサブライブラリです。
拡張子が .rb、.rbw のファイルを解析する事ができます。
=== メタプログラミングされたメソッド
動的に定義されたメソッドをドキュメントに含めたい場合、## で......コメントを開始します。
##
# This is a meta-programmed method!
add_my_method :meta_method, :arg1, :arg2
RDoc::Parser::Ruby は上記の :meta_method ようにメソッドの定義を行
うような識別子の後に続くトークンをメソッド名として解釈します。......、:singleton-method: 命令を指定しま
す。
##
# :singleton-method:
以下のようにメソッド名を指定する事もできます。
##
# :singleton-method: woo_hoo!
また、属性についても同様に :attr:、 :attr_reader:、 :attr_writer:、
:attr_accessor: を指定... -
NEWS for Ruby 3
. 0 . 0 (3300.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 3.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......precation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments.
16378
//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is re......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, Module#attr_reader,... -
JSON
:: Parser . new(source , options => {}) -> JSON :: Parser (3212.0) -
パーサを初期化します。
...偽を指定してください。
: :allow_nan
真を指定すると 4627 を無視して NaN, Infinity, -Infinity をパースエラーにしません。
デフォルトは偽です。
: :create_additions
偽を指定するとマッチするクラスや ID があっても付加情報を生成......array_class
JSON の配列を変換するクラスを指定します。デフォルトは Array です。
@param source パーサの元となる文字列を指定します。
@param options オプションを指定するためのハッシュです。
//emlist[例][ruby]{
require 'json'
parser......定する][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"
person.age #... -
Thread
:: Backtrace :: Location # absolute _ path -> String (3206.0) -
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/to/foo.rb
# /path/to/foo.rb
//}
@see Thread::Backtrace::Locati... -
Thread
:: Backtrace :: Location # base _ label -> String (3206.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).locat......ions.map do |call|
puts call.base_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Location#label... -
Thread
:: Backtrace :: Location # inspect -> String (3206.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......ations.map do |call|
puts call.inspect
end
# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}... -
Thread
:: Backtrace :: Location # to _ s -> String (3206.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.rb:5:in `......initialize'
# path/to/foo.rb:9:in `new'
# path/to/foo.rb:9:in `<main>'
//}...