別のキーワード
キーワード
- !~ (12)
- <=> (12)
- == (12)
- === (12)
- =~ (9)
-
_ dump (12) - clone (12)
-
enum
_ for (24) - eql? (12)
- equal? (12)
- freeze (12)
- frozen? (12)
- hash (12)
- initialize (12)
- inspect (12)
-
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variable _ set (12) -
instance
_ variables (12) -
marshal
_ dump (12) -
marshal
_ load (12) - methods (12)
-
object
_ id (12) -
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
public
_ send (24) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ methods (12) - then (7)
-
to
_ a (12) -
to
_ ary (12) -
to
_ enum (24) -
to
_ int (12) -
to
_ proc (12) -
to
_ regexp (12) -
to
_ s (12) -
to
_ str (12) - trust (9)
- untrust (9)
- untrusted? (9)
-
yield
_ self (8)
検索結果
先頭5件
-
Object
# to _ proc -> Proc (6208.0) -
オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要......に応じてサブクラスで定義すべきものです。
//emlist[][ruby]{
def doing
yield
end
class Foo
def to_proc
Proc.new{p 'ok'}
end
end
it = Foo.new
doing(&it) #=> "ok"
//}... -
Object
# to _ regexp -> Regexp (6208.0) -
オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...オブジェクトの Regexp への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必......ての場面で代置可能であるような、
* 正規表現そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_regexp
/[\d]+/
end
end
it = Foo.new
p Regexp.union(/^at/, it) #=> /(?-mix:^at)|(?-mix:[\d]+)/
//}... -
Object
# trust -> self (6134.0) -
このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。 Object#untaint と同じ動作をします。
...このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。
Object#untaint と同じ動作をします。
@see Object#untrusted?,Object#untrust... -
Object
# untrust -> self (6134.0) -
このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。 Object#taint と同じ動作をします。
...このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。
Object#taint と同じ動作をします。
@see Object#trust,Object#untrusted?... -
Object
# untrusted? -> bool (6134.0) -
このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。 Object#tainted? と同じ動作をします。
...このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。
Object#tainted? と同じ動作をします。
@see Object#trust,Object#untrust... -
Object
# untrusted? -> false (6134.0) -
このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。 Object#tainted? と同じ動作をします。
...このメソッドは Ruby 2.1 から deprecated で、Ruby 3.2 で削除予定です。
Object#tainted? と同じ動作をします。
@see Object#trust,Object#untrust... -
Object
# respond _ to?(name , include _ all = false) -> bool (6126.0) -
オブジェクトがメソッド name を持つとき真を返します。
...きることをいいます。
Windows での Process.fork や GNU/Linux での File.lchmod の
ような NotImplementedError が発生する場合は false を返します。
※ NotImplementedError が発生する場合に false を返すのは
Rubyの組み込みライブラリや標準ライ......メソッドのみです。
Rubyで実装されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字......です。
@param include_all private メソッドと protected メソッドを確認の対象に
含めるかを true か false で指定します。省略した場合
は false(含めない) を指定した事になります。
//emlist[][ruby]{
class F
def... -
Object
# enum _ for(method = :each , *args) -> Enumerator (6114.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep......eat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (6114.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep......eat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end... -
Object
# freeze -> self (6114.0) -
オブジェクトを凍結(内容の変更を禁止)します。
...外 RuntimeError を発生させます。
いったん凍結されたオブジェクトを元に戻す方法はありません。
凍結されるのはオブジェクトであり、変数ではありません。代入などで変数の指す
オブジェクトが変化してしまうことは freez......freeze が防ぐのは、
`破壊的な操作' と呼ばれるもの一般です。変数への参照自体を凍結したい
場合は、グローバル変数なら Kernel.#trace_var が使えます。
@return self を返します。
//emlist[][ruby]{
a1 = "foo".freeze
a1 = "bar"
p a1 #=> "bar"......"foo".freeze
a2.replace("bar") # can't modify frozen String (RuntimeError)
//}
凍結を解除することはできませんが、Object#dup を使えばほぼ同じ内容の凍結されていない
オブジェクトを得ることはできます。
//emlist[][ruby]{
a = [1].freeze
p a.frozen?......外 FrozenError を発生させます。
いったん凍結されたオブジェクトを元に戻す方法はありません。
凍結されるのはオブジェクトであり、変数ではありません。代入などで変数の指す
オブジェクトが変化してしまうことは freeze......reeze
a2.replace("bar") # can't modify frozen String (FrozenError)
//}
凍結を解除することはできませんが、Object#dup を使えばほぼ同じ内容の凍結されていない
オブジェクトを得ることはできます。
//emlist[][ruby]{
a = [1].freeze
p a.frozen? #=> tr... -
Object
# marshal _ dump -> object (6114.0) -
Marshal.#dump を制御するメソッドです。
...Marshal.#dump を制御するメソッドです。
Marshal.dump(some) において、出力するオブジェクト some がメソッド marshal_dump を
持つ場合には、その返り値がダンプされたものが Marshal.dump(some) の返り値となります。
marshal_dump/marshal_load......は Ruby 1.8.0 から導入されました。
これから書くプログラムでは _dump/_load ではなく
marshal_dump/marshal_load を使うべきです。
@return 任意のオブジェクトで marshal_load の引数に利用できます。
//emlist[][ruby]{
class Foo
def initialize(arg)......arg
end
def marshal_dump
@foo
end
def marshal_load(obj)
p obj
@foo = obj
end
end
foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:\bFoo[\a\"\bfoo\"\bbar"
result = Mar...