るりまサーチ

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

別のキーワード

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

検索結果

<< 1 2 3 > >>

クラス (3001.0)

クラス === クラスとオブジェクト

クラス
=== クラスとオブジェクト

Ruby プログラムからはクラスもまたオブジェクトとして扱うことが
でき、文による操作と合わせると以下の基本操作が可能です。

* メソッドの存在を問い合わせる
* メソッドを定義する
* メソッドの定義を取り消す

=== モジュール


=== 特異クラス

1.6.8から1.8.0への変更点(まとめ) (277.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...よくわかりません(^^;

class
<< Object
p [self.id, self]
class
<< self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09...
...-05) [i586-linux]
[537771634, #<Class:Object>]
[537771634, #<Class:Object>]

さらに、オブジェクトの特異クラスのスーパークラスの特異クラスと
オブジェクトの特異クラスの特異クラスのスーパークラスは同じなのだそう...
...(^^;;

class
<< Object.new
class
<< self.superclass
p [self.id, self]
end
class
<< self
p [self.superclass.id, self.superclass]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]...

ruby 1.6 feature (241.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...
...定義形式で特異メソッドを定義できるようにな
りました。

class
<<true
def foo
"foo"
end
end
p true.foo
=> -:1: no virtual class for true (TypeError)
ruby 1.6.6 (2001-12-26) [i586-linux]

=> ru...

クラス/メソッドの定義 (241.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...
...ラス定義は、識別子で指定した定数へのクラスの代入になります
(Ruby では、クラスもオブジェクトの一つで Classクラスの
インスタンスです)。

クラスが既に定義されているとき、さらに同じクラス名でクラス定義を書くと...

変数と定数 (225.0)

変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio

...変数と定数
* local
* instance
* class
* class_var_scope
* global
* pseudo
* const
* prio

Ruby の変数と定数の種別は変数名の最初の一文字によって、
ローカル変数、
インスタンス変数、
クラス変数、
グローバル変数、
定数
のい...
...ら参照できます。初期化されていない
インスタンス変数を参照した時の値はnilです。


===[a:class] クラス変数

//emlist[例][ruby]{
class
Foo
@@foo = 1
def bar
puts @@foo
end
end
//}

@@で始まる変数はクラス変数です。クラス変数はク...
...スで共有される
グローバル変数であるとみなすことができます。

//emlist[][ruby]{
class
Foo
@@foo = 1
end

class
Bar < Foo
p @@foo += 1 # => 2
end

class
Baz < Bar
p @@foo += 1 # => 3
end
//}

モジュールで定義されたクラス変数(モジ...

絞り込み条件を変える

Marshal フォーマット (97.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...nce of the user class

==== String, Regexp, Array, Hash のサブクラス (インスタンス変数なし)

'C' で始まるデータ構造になります。

//emlist{
| 'C' | クラス名(Symbol)の dump | 親クラスのインスタンスの dump |
//}

//emlist[例 1][ruby]{
class
Foo < Array #...
...構造になります。
d:marshal_format#instance_variableも参照してください。

//emlist[例 2: インスタンス変数あり][ruby]{
class
Foo < Array # (or String, Regexp, Hash)
def initialize(obj)
@foo = false
super(obj)
end
end
p Marshal.dump(Foo.new([true])).unpack("x2 a...
...

実装上内部構造が異なるため、上記以外では、'o' になります。
(d:marshal_format#Object 参照)

//emlist[例][ruby]{
class
Foo
end
p Marshal.dump(Foo.new).unpack("x2 a a c a*")
# => ["o", ":", 8, "Foo\x00"]
//}

=== 'u'

_dump、_load を定義していれば 'u' にな...

Ruby プログラムの実行 (97.0)

Ruby プログラムの実行 === Ruby プログラム

...ます。

書式

class
ClassName [< スーパークラス式]

end

クラス定義式は評価されるとまずクラスを生成しようとします。スーパークラ
ス式が指定されていたらそれを評価し、その値を上位クラスとする Class
クラスのイ...
...は例外 TypeError が発生します。

クラスを得たら次にそれを定数「ClassName」に代入します。これによってク
ラス名が決定されます。このとき同名の定数に Class のインスタンスでない
ものが代入されている場合は例外 TypeError...
...が発生します。

最後に新しいフレームを生成し、トップレベルブロックの self および class
に定義を行おうとするクラスを設定して、そのフレーム上で定義式中の式を評
価します。クラス定義式は最後に評価した式の結果...

Ruby用語集 (97.0)

Ruby用語集 A B C D E F G I J M N O R S Y

...

https://mruby.org/

: main
トップレベルにおける self。Object クラスのインスタンスである。

===[a:N] N

: nil
NilClass の唯一のインスタンス。また、そのオブジェクトを指す擬似変数の名前。
論理値としては偽である。

Ruby...
...し、切り替えて使うための
ツールの一つ。Linux、macOS などで動作する。

https://github.com/rbenv/rbenv

: RD(Ruby Document format)
Ruby スクリプト中に記述することを念頭に作られたドキュメントフォーマット。

: RDoc
Ruby スクリ...
...ルが利用する、二つのオブジェクトの順序関係を表す
演算子 <=> の俗称。

: 埋め込みドキュメント
: embedded document
ソースコード中の =begin 行から =end 行まで。コメントとみなされ実行されない。

その名の通り、この部...

NEWS for Ruby 3.0.0 (91.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

==...
...-limit` option limits the maximum length of a backtrace.
8661

== Core classes updates

Outstanding ones only.

* Array
* The following methods now return Array instances instead of subclass instances when called on subclass instances: 6087
* Array#drop
* Array#drop_while
* A...

ruby 1.8.3 feature (79.0)

ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))

...は、$SAFE レベル が 0 のとき
禁止されるようになりました。

$ cat mthd_taint.rb
th = Thread.new{
$SAFE = 3
class
Hoge
def foo
puts "safe level: #{$SAFE}"
end
end
}
th.join
p $SAFE
Hoge.new.foo

$ ruby...
...: Module#class_variable_get [ruby] [new]
: Module#class_variable_set [ruby] [new]

クラスメソッドから((<変数と定数/クラス変数>))にアクセスするための
((<Module#class_variable_get|Module/class_variable_get>)) と
((<Module#class_variable_set|Module/class_variable_...
...した。((<ruby-talk:144741>))

class
Fred
@@foo = 99
def foo
@@foo
end
end

def Fred.foo
@@foo = 101 #=> @@foo は Fred クラスのクラス変数ではない。
end

def Fred.foo_foo
class
_variable_set(:@@foo, 101) # self...

絞り込み条件を変える

<< 1 2 3 > >>