別のキーワード
ライブラリ
- ビルトイン (623)
-
minitest
/ spec (7) - pp (36)
- psych (24)
キーワード
- !~ (12)
- == (12)
- =~ (9)
-
_ dump (12) - class (12)
- clone (12)
- display (12)
- dup (12)
-
enum
_ for (24) - eql? (12)
- equal? (12)
- extend (12)
- freeze (12)
- frozen? (12)
- hash (12)
- initialize (12)
-
initialize
_ copy (12) -
initialize
_ dup (12) - inspect (12)
-
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variable _ set (12) -
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) -
marshal
_ dump (12) - method (12)
- methods (12)
-
must
_ be _ close _ to (1) -
must
_ be _ empty (1) -
must
_ be _ within _ delta (1) -
must
_ be _ within _ epsilon (1) -
must
_ equal (1) -
must
_ match (1) -
must
_ respond _ to (1) - nil? (12)
-
object
_ id (12) -
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
pretty
_ print _ inspect (12) -
private
_ methods (12) -
protected
_ methods (12) -
psych
_ to _ yaml (12) -
public
_ method (12) -
public
_ methods (12) -
public
_ send (24) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ methods (12) - taint (6)
- tainted? (6)
- tap (8)
-
to
_ a (12) -
to
_ ary (12) -
to
_ enum (24) -
to
_ int (12) -
to
_ str (12) -
to
_ yaml (12) - untaint (6)
検索結果
先頭5件
-
Object
# pretty _ print(pp) -> () (12214.0) -
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。
...
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに
呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。
あるクラスの pp の出力をカスタマイズしたい場合は、このメソッドを再定義します。
そのと...... pretty_print メソッドは指定された pp に対して表示したい自身の内容を追加して
いかなければいけません。いくつかの組み込みクラスについて、
pp ライブラリはあらかじめ pretty_print メソッドを定義しています。
@param pp PP......ブジェクトです。
//emlist[][ruby]{
require 'pp'
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}
@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable......オブジェクトです。
//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}
@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable... -
Object
# pretty _ print _ cycle(pp) -> () (12214.0) -
プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。
...、
Object#pretty_print の代わりに呼ばれるメソッドです。
あるクラスの pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。
@param pp PP オブジェクトです。
//emlist[][ruby]{
class Array
def pretty_print......_cycle(q)
q.text(empty? ? '[]' : '[...]')
end
end
//}
@see Object#pretty_print... -
Object
# pretty _ print _ inspect -> String (12208.0) -
Object#pretty_print を使って Object#inspect と同様に オブジェクトを人間が読める形式に変換した文字列を返します。
...
Object#pretty_print を使って Object#inspect と同様に
オブジェクトを人間が読める形式に変換した文字列を返します。
出力する全てのオブジェクトに Object#pretty_print が定義されている必要があります。
そうでない場合には RuntimeEr......ror が発生します。
@raise RuntimeError 出力する全てのオブジェクトに Object#pretty_print が定義されて
いない場合に発生します。... -
Object
# must _ be _ within _ epsilon(actual , epsilon = 0 . 001) -> true (6220.0) -
自身と実際の値の相対誤差が許容範囲内である場合、検査にパスしたことになります。
...実際の値の相対誤差が許容範囲内である場合、検査にパスしたことになります。
@param actual 実際の値を指定します。
@param epsilon 許容する相対誤差を指定します。
@raise MiniTest::Assertion 検査に失敗した場合に発生します。... -
Object
# marshal _ dump -> object (6168.0) -
Marshal.#dump を制御するメソッドです。
...Marshal.#dump を制御するメソッドです。
Marshal.dump(some) において、出力するオブジェクト some がメソッド marshal_dump を
持つ場合には、その返り値がダンプされたものが Marshal.dump(some) の返り値となります。
marshal_dump/marshal_load......dump/_load ではなく
marshal_dump/marshal_load を使うべきです。
@return 任意のオブジェクトで marshal_load の引数に利用できます。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def marshal_dump
@foo
end
def marshal_load(obj)
p ob......foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:\bFoo[\a\"\bfoo\"\bbar"
result = Marshal.load(dms) #=> ["foo", "bar"] # marshal_load の引数
p result #=> #<Foo:0xbaf2ac @foo=["foo", "... -
Object
# _ dump(limit) -> String (6162.0) -
Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。
...Marshal.#dump において出力するオブジェクトがメソッド _dump
を定義している場合には、そのメソッドの結果が書き出されます。
バージョン1.8.0以降ではObject#marshal_dump, Object#marshal_loadの使用
が推奨されます。 Marshal.dump するオ......mp と marshal_dump の両方の
メソッドを持つ場合は marshal_dump が優先されます。
メソッド _dump は引数として再帰を制限するレベル limit を受
け取り、オブジェクトを文字列化したものを返します。
インスタンスがメソッド _dump......あります。
@param limit 再帰の制限レベルを表す整数です。
@return オブジェクトを文字列化したものを返すように定義すべきです。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def _dump(limit)
Marshal.dump(@foo, limit)
en... -
Object
# initialize _ copy(obj) -> object (6144.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...数や特異メソッドは変化しません。
デフォルトでは、Object#clone の内部で Object#initialize_clone から、
また Object#dup の内部で Object#initialize_dup から呼ばれます。
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーする......lize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_copy と......のメソッドは
自動的に private に設定されます。
@raise TypeError レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#clone,Object#dup
以下に例として、dup や clone がこのメソッ... -
Object
# inspect -> String (6132.0) -
オブジェクトを人間が読める形式に変換した文字列を返します。
...み込み関数 Kernel.#p は、このメソッドの結果を使用して
オブジェクトを表示します。
//emlist[][ruby]{
[ 1, 2, 3..4, 'five' ].inspect # => "[1, 2, 3..4, \"five\"]"
Time.new.inspect # => "2008-03-08 19:43:39 +0900"
//}
inspect メソッドをオーバ......変数の名前、値の組を元にした文字列を返します。
//emlist[][ruby]{
class Foo
end
Foo.new.inspect # => "#<Foo:0x0300c868>"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
//}
@see Kernel.#p... -
Object
# public _ method(name) -> Method (6132.0) -
オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。
...クトの public メソッド name をオブジェクト化した
Method オブジェクトを返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メ......ソッド名を引数として与えると発生します。
//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}
@see Object#method,Object#public_send,Module#public_instance_method... -
Object
# public _ send(name , *args) -> object (6132.0) -
オブジェクトの public メソッド name を args を引数にして呼び出し、メソッ ドの実行結果を返します。
...ブジェクトの public メソッド name を args を引数にして呼び出し、メソッ
ドの実行結果を返します。
ブロック付きで呼ばれたときはブロックもそのまま引き渡します。
//emlist[][ruby]{
1.public_send(:+, 2) # => 3
//}
@param name 文字列......かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。
@raise ArgumentError name を指定しなかった場合に発生します。
@raise NoMethodError protected メソッドや private メソッドに対して実行......した場合に発生します。
//emlist[][ruby]{
1.public_send(:puts, "hello") # => NoMethodError
//}
@see BasicObject#__send__, Object#send...