種類
- インスタンスメソッド (260)
- 文書 (67)
- 特異メソッド (66)
- ライブラリ (22)
- クラス (11)
ライブラリ
- ビルトイン (194)
- erb (11)
- forwardable (22)
- json (44)
- psych (11)
-
rdoc
/ top _ level (11) - tracer (22)
- win32ole (22)
クラス
- BasicObject (22)
- ERB (11)
-
JSON
:: Parser (22) - Module (18)
- Object (22)
-
RDoc
:: TopLevel (11) -
Thread
:: Backtrace :: Location (44) - Tracer (22)
-
WIN32OLE
_ EVENT (11) -
WIN32OLE
_ TYPE (11)
モジュール
- Enumerable (88)
- Forwardable (22)
- JSON (11)
-
JSON
:: Generator :: GeneratorMethods :: Object (11)
キーワード
- ! (11)
- != (11)
- Location (11)
-
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) -
absolute
_ path (11) -
attr
_ accessor (3) -
attr
_ reader (3) -
attr
_ writer (3) -
base
_ label (11) - cgi (11)
-
create
_ id (11) -
def
_ delegator (11) -
def
_ instance _ delegator (11) -
default
_ event _ sources (11) -
find
_ local _ symbol (11) - handler= (11)
-
initialize
_ copy (11) - inspect (11)
- max (44)
- min (44)
- new (22)
- parse (11)
-
rexml
/ parsers / streamparser (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 9 feature (11) -
set
_ get _ line _ procs (22) -
to
_ json (11) -
to
_ s (11) -
yaml
_ tag (11) - クラス/メソッドの定義 (11)
- 演算子式 (11)
検索結果
先頭5件
-
Module
# attr(*name) -> [Symbol] (18121.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...読み取りのためのインスタンスメソッド name を定義します。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義... -
Module
# attr(name , false) -> [Symbol] (18121.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...読み取りのためのインスタンスメソッド name を定義します。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義... -
Module
# attr(name , true) -> [Symbol] (18121.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...読み取りのためのインスタンスメソッド name を定義します。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義... -
Module
# attr _ accessor(*name) -> [Symbol] (6119.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...りメソッドと書き込みメソッドの両方を
定義します。
//emlist[例][ruby]{
class User
attr_accessor :name # => [:name, :name=]
# 複数の名前を渡すこともできる
attr_accessor :id, :age # => [:id, :id=, :age, :age=]
end
//}
このメソッドで定義される... -
Module
# attr _ reader(*name) -> [Symbol] (6119.0) -
インスタンス変数 name の読み取りメソッドを定義します。
...インスタンス変数 name の読み取りメソッドを定義します。
//emlist[例][ruby]{
class User
attr_reader :name # => [:name]
# 複数の名前を渡すこともできる
attr_reader :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるメソッドの定義... -
Module
# attr _ writer(*name) -> [Symbol] (6119.0) -
インスタンス変数 name への書き込みメソッド (name=) を定義します。
...ンス変数 name への書き込みメソッド (name=) を定義します。
//emlist[例][ruby]{
class User
attr_writer :name # => [:name=]
# 複数の名前を渡すこともできる
attr_writer :id, :age # => [:id=, :age=]
end
//}
このメソッドで定義されるメソッドの定... -
RDoc
:: TopLevel # find _ local _ symbol(name) -> RDoc :: NormalClass | RDoc :: SingleClass | RDoc :: NormalModule | RDoc :: AnyMethod | RDoc :: Alias | RDoc :: Attr | RDoc :: Constant (301.0) -
クラス、モジュール、メソッド、定数、属性、alias、ファイルから name で指定したものを返します。見つからなかった場合は nil を返します。
クラス、モジュール、メソッド、定数、属性、alias、ファイルから name で指定したものを返します。見つからなかった場合は nil を返します。 -
ruby 1
. 6 feature (252.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))
class Foo
FOO = 1
@@foo = 1
end
FOO = 2
@@foo = 2
Foo.module_eval { p FOO, @@foo }
=......列を返すようになった
: 2002-03-08 class variable
((<ruby-talk:35122>))
class C
class << self
def test
@@cv = 5
p @@cv
end
end
test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
fr......ことがありました。((<ruby-dev:13752>))
: attr_*
アクセサに余計な引数を渡してもエラーになりませんでした。
((<ruby-dev:13748>))
class C
def initialize
@message = 'ok'
end
attr_reader :message
end
puts C.new.message(1,2,3... -
クラス/メソッドの定義 (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 (120.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
==......les and 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_acces... -
NEWS for Ruby 3
. 1 . 0 (54.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* Class
* 新規メソッド
* Class#subclassesはレシーバを継承した子クラスを要素に持つ配列(シングルトンクラスを含まない)を返します。
//emlist[Class#subclasses][ruby]{
class A; end
class B < A; end
class C < B; end
class D < A; end
A.subclasses......#=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}
* Enumerable
* 新規メソッド
* Enumerable#compactが追加されました。 17312
* Enumerable#tallyがカウント集計用のハッシュオブジェクトを任意で渡せるようになりました。 1774......ith the `_Output` interface.
# `PrettyPrint[String]` is ok, but `PrettyPrint[Integer]` is a type error.
class PrettyPrint[T < _Output]
interface _Output
def <<: (String) -> void
end
attr_reader output: T
def initialize: (T output) -> void
end
//}
* ジェネリックな型エイリ... -
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... -
演算子式 (36.0)
-
演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond
...ェクトに対しての、式 2 から式 n までを
引数とする []= メソッド呼び出しに変換されます。
//emlist[例][ruby]{
class C
def initialize
@ary = [0,1,2,3,4,5,6,7]
end
def [](i)
@ary[i * 2]
end
def []=( i, v )
@ary[i * 2] = v
end
end
c = C.new......ist[例][ruby]{
class C
def foo
@foo
end
def foo=( v )
@foo = v
end
end
c = C.new
c.foo = 5 # c.foo=( 5 ) のように変換される
p c.foo # => 5
//}
属性は Module#attr を使って同じように定義できます。
//emlist[例][ruby]{
class C
attr :foo, true
end......z = [1, 2], 3 # foo = 1; bar = 2; baz = 3
//}
特殊な形式の代入式も多重代入にすることができます。
//emlist[][ruby]{
class C
def foo=( v )
@foo = v
end
def []=(i,v)
@bar = ["a", "b", "c"]
@bar[i] = v
end
end
obj = C.new
obj.foo, obj[2] = 1, 2 #... -
JSON
. create _ id -> String (30.0) -
json_create メソッドで使用するクラスを決定するために使用する値を返します。
...は "json_class" です。
//emlist[例][ruby]{
require "json"
class User
attr :id, :name
def initialize(id, name)
@id, @name = id, name
end
def self.json_create(object)
new(object['id'], object["name"])
end
def as_json(*)
{
JSON.create_id => self.class.name,......> id,
"name" => name,
}
end
def to_json(*)
as_json.to_json
end
end
json = JSON.generate(User.new(1, "tanaka"))
json # => "{\"json_class\":\"User\",\"id\":1,\"name\":\"tanaka\"}"
JSON.parse(json, create_additions: true)
# => #<User:0x0000557709b269e0 @id=1, @name="tanaka">
//}... -
NEWS for Ruby 2
. 5 . 0 (30.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* 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, Module#u......の場合:
//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桁... -
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...