種類
- 文書 (77)
- 特異メソッド (22)
- インスタンスメソッド (21)
ライブラリ
- ビルトイン (43)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Ruby用語集 (11)
- new (22)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) -
super
_ method (10) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Class
# superclass -> Class | nil (18262.0) -
自身のスーパークラスを返します。
...ile.superclass #=> IO
IO.superclass #=> Object
class Foo; end
class Bar < Foo; end
Bar.superclass #=> Foo
Object.superclass #=> BasicObject
//}
ただし BasicObject.superclass は nil を返します。
//emlist[例][ruby]{
BasicObject.superclass #=> nil
//}... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (1254.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への変更点(まとめ)/サポートプラットフォームの追加>))
...りました。
* nil: 警告を出力しない (-W0 新しい警告レベル)
* false: 重要な警告のみ出力 (-W1 デフォルト)
* true: すべての警告を出力する (-W2 or -W or -v or -w or --verbose)
追加された -W オプションは $VERBOSE = nil の指定(-W0)を......よくわかりません(^^;
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......りません(^^;;
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, C... -
クラス/メソッドの定義 (672.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ス定義
//emlist[例][ruby]{
class Foo < Super
def test
# ...
end
# ...
end
//}
文法:
class 識別子 [`<' superclass ]
式..
end
文法:
class 識別子 [`<' superclass ]
式..
[rescue [error_type,..] [=> evar] [then......]
式..]..
[else
式..]
[ensure
式..]
end
クラスを定義します。クラス名はアルファベットの大文字で始まる識別子です。
rescue/ensure 節を指定し、例外処理ができます。
例外処理に......返さない場合は nil を返します。
===[a:singleton_class] 特異クラス定義
//emlist[例][ruby]{
obj = Object.new # obj = nil でも可
class << obj
def test
# ...
end
# ...
end
//}
文法:
class `<<' expr
式..
end
文法:
clas... -
ruby 1
. 6 feature (570.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
... nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)
p "foo".slice!("bar") # <- 以前からこちらは nil を返していた
p "foo".slice!(5,10)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil......ーになっていました。
((<ruby-dev:17155>))
open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3......ークラスが反映されていません
でした。((<ruby-bugs-ja:PR#87>))
class A
p self.id
end
class A < String
p self.id
p self.superclass
end
=> ruby 1.6.5 (2001-09-19) [i586-linux]
537760880
-:4: warning: already initialized constant... -
Class
. new(superclass = Object) -> Class (148.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...新しく名前の付いていない superclass のサブクラスを生成します。
名前のないクラスは、最初に名前を求める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # =>......#<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name # => "Bar" ("Foo" になるか "Bar" になるかは不定)
//}
ブロックが与えられた場合、生成したクラスを引数として
クラスの......は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.h... -
Class
. new(superclass = Object) {|klass| . . . } -> Class (148.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...新しく名前の付いていない superclass のサブクラスを生成します。
名前のないクラスは、最初に名前を求める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # =>......#<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name # => "Bar" ("Foo" になるか "Bar" になるかは不定)
//}
ブロックが与えられた場合、生成したクラスを引数として
クラスの......は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.h... -
ruby 1
. 8 . 2 feature (138.0) -
ruby 1.8.2 feature ruby 1.8.2 での ruby 1.8.1 からの変更点です。
...子以外では nil を 0 に変換しなくなりました。
$ ruby-1.8.1 -e 'p [nil].pack("L")'
"\000\000\000\000"
$ ruby-1.8.2 -e 'p [nil].pack("L")'
-e:1:in `pack': cannot convert nil into Integer (TypeError)
from -e:1
$ ruby-1.8.2 -e 'p [nil].pack("P")'......]
セッションを保存するファイル名にセッション ID が使われるバグを修正しました。
=== 2004-08-23
: OpenSSL::SSL#pending [lib] [new]
=== 2004-08-14
: FileUtils.copy_entry [lib] [new]
: FileUtils::DryRun [lib] [new]
追加。
: FileUtils.mv [lib] [compat]
mv......5-10
: superclass mismatch [ruby] [change]
親クラスの違う同じ名前のクラスを再定義した時 TypeError を投げるようになりました。
((<ruby-list:39567>))
$ ruby-1.8.2 -e '
class Foo
Bar = 1
end
class Foo < String
Baz = 2
end... -
Method
# super _ method -> Method | nil (137.0) -
self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。
...][ruby]{
class Super
def foo
"superclass method"
end
end
class Sub < Super
def foo
"subclass method"
end
end
m = Sub.new.method(:foo) # => #<Method: Sub#foo>
m.call # => "subclass method"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}... -
ruby 1
. 8 . 3 feature (114.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...た。
$ 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-1.8.2 mthd_taint.rb
0
"safe level: 0"
$ ruby-1.8.3 mthd_ta......オプションに -w を付けた時に出ます。((<ruby-dev:26201>))
=== 2005-05-22
: OpenSSL::SSL::SSLServer#initialize(svr, ctx, session_id=nil)
session_id を受け付けるようになりました。((<ruby-core:4663>))
=== 2005-05-19
: REXML::Encoding#decode_sjis [lib] [bug]
: REXML::......er [lib] [bug]
継承するとエラーになるバグを修正。 ((<ruby-talk:126104>))
=== 2005-01-12
: Class#superclass [ruby] [bug]
特異クラスのメソッド superclass が特異クラスを返すように修正されました。
((<ruby-list:40519>))
=== 2005-01-09
: IO#read [ob... -
ruby 1
. 8 . 4 feature (84.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...適合する文字列を厳密にした。((<ruby-core:03573>)),((<ruby-dev:27478>))
1) alias :"foo" :"bar"
def bar; p "bar"; end
alias :"foo" :"bar"
foo
# => ruby 1.8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpecte......]
Kernelのメソッド内でsuperを呼んだ時に、存在しないsuperclass
にアクセスしようとするバグの修正。
module Kernel
def foo
super
end
end
foo
# => ruby 1.8.3 (2005-09-21) [i686-linux]......z]+x[0-9]+$/ =~ "hogex111")
p(/^[\x61-\x7a]+x[0-9]+$/ =~ "hogex111")
# => ruby 1.8.3 (2005-09-21) [i686-linux]
0
nil
# => ruby 1.8.4 (2005-12-22) [i686-linux]
0
0
: シグナル [bug]
#Sun Oct 16 03:38:07 2005 Yukihiro M...