クラス
-
ARGF
. class (66) -
JSON
:: Parser (11) - Module (11)
- Object (22)
- Set (11)
- Thread (22)
- TracePoint (11)
モジュール
- Enumerable (22)
キーワード
-
add
_ trace _ func (11) -
class
_ variable _ set (11) - classify (11)
-
defined
_ class (11) -
external
_ encoding (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
internal
_ encoding (11) - parse (11)
- seek (11)
-
set
_ encoding (33) -
set
_ trace _ func (11) -
to
_ set (22)
検索結果
先頭5件
-
Set
# classify {|o| . . . } -> Hash (27131.0) -
集合をブロックの値によって分類し、結果をハッシュとして返します。
...ます。
生成されるハッシュのキーはブロックの実行結果、値は分類された集合と
なります。
//emlist[][ruby]{
require 'set'
numbers = Set[10, 4.5, 20, 30, 31.2]
p numbers.classify {|o| o.class}
# => {Integer=>#<Set: {10, 20, 30}>, Float=>#<Set: {4.5, 31.2}>}
//}... -
Module
# class _ variable _ set(name , val) -> object (12221.0) -
クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。
...をセットします。val を返します。
@param name String または Symbol を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end
def Fred.foo(val)
class_variable_set(:@@foo, val)
end
p Fred.foo(101) # => 101
p Fred.new.foo # => 101
//}... -
ARGF
. class # set _ encoding(enc _ str , options = {}) -> self (9110.0) -
ARGF の外部/内部エンコーディングを設定します。 次以降に処理するファイルにも同じ設定が適用されます。
...して読み込むファイルの、
内部エンコーディングは読み込んだ文字列のエンコーディングです。
詳しくは IO#set_encoding を参照してください。
@param enc_str 外部/内部エンコーディングを"A:B" のようにコロンで
区... -
ARGF
. class # set _ encoding(ext _ enc) -> self (9110.0) -
ARGF の外部/内部エンコーディングを設定します。 次以降に処理するファイルにも同じ設定が適用されます。
...して読み込むファイルの、
内部エンコーディングは読み込んだ文字列のエンコーディングです。
詳しくは IO#set_encoding を参照してください。
@param enc_str 外部/内部エンコーディングを"A:B" のようにコロンで
区... -
ARGF
. class # set _ encoding(ext _ enc , int _ enc , options = {}) -> self (9110.0) -
ARGF の外部/内部エンコーディングを設定します。 次以降に処理するファイルにも同じ設定が適用されます。
...して読み込むファイルの、
内部エンコーディングは読み込んだ文字列のエンコーディングです。
詳しくは IO#set_encoding を参照してください。
@param enc_str 外部/内部エンコーディングを"A:B" のようにコロンで
区... -
Enumerable
# to _ set(klass = Set , *args) -> Set (6379.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...合オブジェクトを作ります。
引数 klass を与えた場合、Set クラスの代わりに、指定した集合クラスの
インスタンスを作ります。
この引数を指定することで、SortedSet あるいはその他のユーザ定義の
集合クラスのインスタン....../emlist[][ruby]{
require 'set'
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
p [30, 10, 20].to_set(SortedSet)
#=> #<SortedSet: {10, 20, 30}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
Enumerable
# to _ set(klass = Set , *args) {|o| . . . } -> Set (6379.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...合オブジェクトを作ります。
引数 klass を与えた場合、Set クラスの代わりに、指定した集合クラスの
インスタンスを作ります。
この引数を指定することで、SortedSet あるいはその他のユーザ定義の
集合クラスのインスタン....../emlist[][ruby]{
require 'set'
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
p [30, 10, 20].to_set(SortedSet)
#=> #<SortedSet: {10, 20, 30}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
Enumerable
# to _ set(klass = Set , *args) -> Set (6373.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...えた場合、Set クラスの代わりに、指定した集合クラスの
インスタンスを作ります。
この引数を指定することで、ユーザ定義の集合クラスのインスタンスを作ることができます
(ここでいう集合クラスとは、Setとメソッド/ク......ラスメソッドで互換性のあるクラスです。
Ruby 2.7 以前は SortedSet が定義されていました)。
引数 args およびブロックは、集合オブジェクトを生成するための new
メソッドに渡されます。
@param klass 生成する集合クラスを指定......urn 生成された集合オブジェクトを返します。
//emlist[][ruby]{
require 'set'
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
Enumerable
# to _ set(klass = Set , *args) {|o| . . . } -> Set (6373.0) -
Enumerable オブジェクトの要素から、新しい集合オブジェクトを作ります。
...えた場合、Set クラスの代わりに、指定した集合クラスの
インスタンスを作ります。
この引数を指定することで、ユーザ定義の集合クラスのインスタンスを作ることができます
(ここでいう集合クラスとは、Setとメソッド/ク......ラスメソッドで互換性のあるクラスです。
Ruby 2.7 以前は SortedSet が定義されていました)。
引数 args およびブロックは、集合オブジェクトを生成するための new
メソッドに渡されます。
@param klass 生成する集合クラスを指定......urn 生成された集合オブジェクトを返します。
//emlist[][ruby]{
require 'set'
p [30, 10, 20].to_set
#=> #<Set: {30, 10, 20}>
MySet = Class.new(Set)
p [30, 10, 20].to_set(MySet)
#=> #<MySet: {10, 20, 30}>
p [30, 10, 20].to_set {|num| num / 10}
#=> #<Set: {3, 1, 2}>
//}
@see Set.new... -
TracePoint
# defined _ class -> Class | module (6263.0) -
メソッドを定義したクラスかモジュールを返します。
...メソッドを定義したクラスかモジュールを返します。
//emlist[例][ruby]{
class C; def foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => C
end.enable do
C.new.foo
end
//}
メソッドがモジュールで定義されていた場合も(include に......M; def foo; end; end
class C; include M; end;
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => M
end.enable do
C.new.foo
end
//}
[注意] 特異メソッドを実行した場合は TracePoint#defined_class は特異クラ
スを返します。また、Kernel.#set_trace_func の 6......ラスではなく元のクラスを返します。
//emlist[例][ruby]{
class C; def self.foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end.enable do
C.foo
end
//}
Kernel.#set_trace_func と TracePoint の上記の差分に注意して
ください。... -
Thread
# set _ trace _ func(pr) -> Proc | nil (6150.0) -
スレッドにトレース用ハンドラを設定します。
...ad.new do
class Trace
end
2.to_s
Thread.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join
# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x00007fc8de886770>, Class]
# => ["......c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => [......"c-return", "example.rb", 5, :current, #<Binding:0x00007fc8de9673b0>, Thread]
# => ["c-call", "example.rb", 5, :set_trace_func, #<Binding:0x00007fc8de966fc8>, Thread]
//}
@param pr トレースハンドラ(Proc オブジェクト) もしくは nil
@see Thread#add_trace_func Kernel.#set_trace_func... -
ARGF
. class # seek(offset , whence = IO :: SEEK _ SET) -> 0 (3202.0) -
ARGFが現在開いているファイルのファイルポインタを whence の位置から offset だけ移動させます。 offset 位置への移動が成功すれば 0 を返します。
...GFが現在開いているファイルのファイルポインタを whence の位置から
offset だけ移動させます。 offset 位置への移動が成功すれば 0 を返します。
@param offset ファイルポインタを移動させるオフセットを整数で指定します。
@para...