704件ヒット
[1-100件を表示]
(0.134秒)
種類
- インスタンスメソッド (603)
- 定数 (90)
- 特異メソッド (11)
ライブラリ
- ビルトイン (640)
-
minitest
/ spec (9) - pp (22)
- psych (33)
キーワード
- !~ (11)
- <=> (11)
- == (11)
- === (11)
- =~ (9)
- DATA (11)
- FALSE (8)
- NIL (8)
-
RUBY
_ PATCHLEVEL (11) -
RUBY
_ PLATFORM (11) -
RUBY
_ RELEASE _ DATE (11) -
SCRIPT
_ LINES _ _ (11) -
TOPLEVEL
_ BINDING (11) - TRUE (8)
-
_ dump (11) - class (11)
- clone (11)
-
define
_ singleton _ method (22) - display (11)
- dup (11)
- eql? (11)
- equal? (11)
- extend (11)
- freeze (11)
- frozen? (11)
- initialize (11)
-
initialize
_ copy (11) -
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
is
_ a? (11) - itself (11)
-
kind
_ of? (11) -
marshal
_ dump (11) -
marshal
_ load (11) - methods (11)
-
must
_ be _ close _ to (1) -
must
_ be _ instance _ of (1) -
must
_ be _ kind _ of (1) -
must
_ be _ nil (1) -
must
_ be _ same _ as (1) -
must
_ be _ within _ delta (1) -
must
_ be _ within _ epsilon (1) -
must
_ equal (1) -
must
_ include (1) - nil? (11)
-
pretty
_ print _ cycle (11) -
pretty
_ print _ instance _ variables (11) -
private
_ methods (11) -
protected
_ methods (11) -
psych
_ to _ yaml (11) -
public
_ method (11) -
public
_ methods (11) -
public
_ send (22) -
remove
_ instance _ variable (11) -
respond
_ to? (11) -
respond
_ to _ missing? (11) -
singleton
_ class (11) -
singleton
_ method (11) -
singleton
_ methods (11) - taint (9)
- tainted? (9)
- tap (11)
-
to
_ yaml (11) - trust (9)
- untaint (9)
- untrust (9)
- untrusted? (9)
-
yaml
_ tag (11) -
yield
_ self (14)
検索結果
先頭5件
-
Object
# class -> Class (6301.0) -
レシーバのクラスを返します。
...レシーバのクラスを返します。
//emlist[][ruby]{
p "ruby".class #=> String
p 100.class #=> Integer
p ARGV.class #=> Array
p self.class #=> Object
p Class.class #=> Class
p Kernel.class #=> Module
//}
@see Class#superclass,Object#kind_of?,Object#instance_of?... -
Object
# must _ be _ within _ delta(expected , delta = 0 . 001) -> true (6301.0) -
自身と期待値の差の絶対値が与えられた絶対誤差以下である場合、検査にパスしたことになります。
...@param expected 期待値を指定します。
@param delta 許容する絶対誤差を指定します。
@raise MiniTest::Assertion 与えられた期待値と実際の値の差の絶対値が与えられた差分を越える場合に発生します。
@see MiniTest::Assertions#assert_in_delta... -
Object
# must _ be _ within _ epsilon(actual , epsilon = 0 . 001) -> true (6301.0) -
自身と実際の値の相対誤差が許容範囲内である場合、検査にパスしたことになります。
...と実際の値の相対誤差が許容範囲内である場合、検査にパスしたことになります。
@param actual 実際の値を指定します。
@param epsilon 許容する相対誤差を指定します。
@raise MiniTest::Assertion 検査に失敗した場合に発生します。... -
Object
:: FALSE -> FalseClass (6301.0) -
非推奨です。代表的な偽の値。false と同じ。
...す。代表的な偽の値。false と同じ。
この定数は過去との互換性のために提供されています。擬似変数 false を使ってください。
Ruby では false と nil が偽として扱われます。
偽でない値(false でも nil でもない値) は全て真とみ... -
Object
# initialize _ copy(obj) -> object (6219.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...期化メソッド。
このメソッドは self を obj の内容で置き換えます。ただ
し、self のインスタンス変数や特異メソッドは変化しません。
Object#clone, Object#dupの内部で使われています。
initialize_copy は、Ruby インタプリタが知り......initialize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_cop......riables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
obj.taint
check Object.new.send(:initialize_copy, obj)
#=> instance variables: #<Object:0x4019c9d4>
# tainted?: false......j = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
check Object.new.send(:initialize_copy, obj)
#=> in... -
Object
. yaml _ tag(tag) -> () (6219.0) -
クラスと tag の間を関連付けます。
...tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
@param tag 対象のクラスに関連付けるタグの文字列
=== Example
require 'psych'
class Foo
def initialize(x)
@x = x
end......umps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3
# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>
# --- !<tag:example.com,2013:foo>
# x:......3
# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>... -
Object
# display(out = $ stdout) -> nil (6207.0) -
オブジェクトを out に出力します。
...//emlist[][ruby]{
class Object
def display(out = $stdout)
out.write self
nil
end
end
//}
@param out 出力先のIOオブジェクトです。指定しない場合は標準出力に出力されます。
@return nil を返します。
//emlist[][ruby]{
Object.new.display #=> #<Object:0xb......b0210>
//}
@see $stdout... -
Object
# public _ method(name) -> Method (6207.0) -
オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。
...オブジェクトの public メソッド name をオブジェクト化した
Method オブジェクトを返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、......vate メソッド名を引数として与えると発生します。
//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
# singleton _ class -> Class (6207.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
...nil か true か false なら、それぞれ NilClass, TrueClass,
FalseClass を返します。
@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... -
Object
# singleton _ method(name) -> Method (6207.0) -
オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。
...aram name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。
//emlist[][ruby]{
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k =......o.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}
@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#method... -
Object
# <=>(other) -> 0 | nil (6201.0) -
self === other である場合に 0 を返します。そうでない場合には nil を返します。
...self === other である場合に 0 を返します。そうでない場合には nil を返します。
//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}
@see Object#===... -
Object
# clone(freeze: true) -> object (6201.0) -
オブジェクトの複製を作成して返します。
...報をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass, FalseClass, NilClass, Symbol, そして Numeric ク......ueClass などの常に freeze されているオブジェクトの freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
obj.taint
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> t......#=> true
p(obj_c.respond_to?(:fuga)) #=> true
obj_d = obj.dup
p(obj.equal?(obj_d)) #=> false
p(obj == obj_d) #=> true
p(obj_d.tainted?) #=> true
p(obj_d.frozen?) #=> false
p(obj_d.respond_to?(:fuga)) #=> false
//}
@see Object#initialize_copy
===...