るりまサーチ

最速Rubyリファレンスマニュアル検索!
426件ヒット [1-100件を表示] (0.034秒)

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. class new
  5. argf.class gets

検索結果

<< 1 2 3 ... > >>

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...
<< 1 2 3 ... > >>