別のキーワード
種類
- 文書 (48)
- インスタンスメソッド (36)
ライブラリ
- ビルトイン (36)
キーワード
-
NEWS for Ruby 2
. 1 . 0 (12) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (12)
- Ruby用語集 (12)
-
private
_ class _ method (24) - クラス/メソッドの定義 (12)
検索結果
先頭5件
-
Object
# singleton _ class -> Class (18131.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
...します。
@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。
//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
nil.singleton_class #=> NilClass
//}
@see Object#class... -
Ruby用語集 (84.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...cent
: 0 オリジン
: zero-based
番号が 0 から始まること。
例えば、
Array や Vector、Matrix などの要素の番号、
String における文字の位置、
といったものは 0 オリジンである。
: 1 オリジン
: one-based
番号が 1 から始まるこ......は
オブジェクトではない。
ただし、メソッド、ブロックはそれぞれオブジェクト化できる。
なお、「String オブジェクト」のような、クラス名+「オブジェクト」の
形の表現は、そのクラスのインスタンスを指す。......自身が属すクラスとは別に、オブジェクト固有の
クラスがあり、特異クラスと呼ばれる。
参照:Object#singleton_class
: 特異メソッド
: singleton method
オブジェクト固有のメソッド。
オブジェクトの特異クラスのインスタ... -
NEWS for Ruby 2
. 1 . 0 (48.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...: Module#using, which activates refinements of the specified module only
in the current class or module definition.
* 追加: Module#singleton_class? レシーバーが特異クラスであれば true を返します。
レシーバーが通常のクラスやモジュールであれ......k_getres
* String
* "literal".freeze は同じオブジェクトを返すように最適化されました。
* 追加: String#scrub, String#scrub! 不正なバイト列を検証して修正します。
古いバージョンのRubyと一緒に使いたいときは string-scrub gem......を使います。
* Symbol
* 全てのシンボルは freeze されるようになりました
* pack/unpack (Array/String)
* プラットフォームが対応していれば Q! と q! は long long 型を表します
* toplevel
* main.using はもはや実験的な機能では... -
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (48.0)
-
Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or plus minus ast slash hat sq period comma langl rangl eq tilde dollar at under lbrarbra lbra2rbra2 lbra3rbra3 dq colon ac backslash semicolon
...: /xxx/ !~ yyy
正規表現のメソッド =~ の否定。マッチが失敗したらtrueを返します。
===[a:q] ?
: ?a
d:spec/literal#string。長さ 1 の文字列。
: def xx?
この場合の「?」はメソッド名の一部分です。
慣用的に、真偽値を返すタイプ......算子。整数クラスでは「剰余」を意味するメソッド。Numeric#%メソッドなどを参照。
: "%04b" % 10
Stringクラスの「%」演算子。String#% メソッド。文字列中ではフォーマット指定子としても使われる。
: %r{/etc/httpd/logs$} や %w[foo b......クラス定義でスーパークラスを指定しています。
d:spec/def#class。
: class << obj
特異クラス定義。d:spec/def#singleton_classを参照。
===[a:rangl] >
: 3 > 5
「より大きい」比較演算子
: 3 >= 5
「より大きいか等しい」比較演算子
: 3... -
クラス/メソッドの定義 (28.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
* d......ray を明示的に指定しても同じ)
class Foo
def bar
end
end
# 間違ったスーパークラスを指定するとエラー
class Foo < String
end
# => superclass mismatch for class Foo (TypeError)
//}
クラス定義式の中は self がそのクラスであることと、
limitのデ......は、最後に評価した式の結果を返します。最後に評価した式
が値を返さない場合は nil を返します。
===[a:singleton_class] 特異クラス定義
//emlist[例][ruby]{
obj = Object.new # obj = nil でも可
class << obj
def test
# ...
end
# ...
end
//}... -
Module
# private _ class _ method(*name) -> self (24.0) -
name で指定したクラスメソッド (クラスの特異メソッド) の 可視性を private に変更します。
...更します。
@param name 0 個以上の String または Symbol を指定します。
@param names 0 個以上の String または Symbol を Array で指定します。
//emlist[例][ruby]{
module Foo
def self.foo; end
end
Foo.singleton_class.private_method_defined?(:foo) # => false
Foo.pr... -
Module
# private _ class _ method(names) -> self (24.0) -
name で指定したクラスメソッド (クラスの特異メソッド) の 可視性を private に変更します。
...更します。
@param name 0 個以上の String または Symbol を指定します。
@param names 0 個以上の String または Symbol を Array で指定します。
//emlist[例][ruby]{
module Foo
def self.foo; end
end
Foo.singleton_class.private_method_defined?(:foo) # => false
Foo.pr...