ライブラリ
- ビルトイン (2773)
- csv (36)
- date (12)
- drb (24)
- fiber (8)
- gdbm (36)
-
io
/ console (36) -
irb
/ context (12) - matrix (60)
- mkmf (36)
-
net
/ http (36) -
net
/ imap (12) -
net
/ pop (132) -
net
/ smtp (32) - observer (12)
- openssl (48)
- optparse (168)
- ostruct (24)
- pathname (24)
- pp (24)
- prime (72)
- pstore (36)
-
rdoc
/ markup (12) -
rexml
/ document (120) - sdbm (12)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (12) - socket (132)
- thread (12)
- timeout (16)
- tracer (12)
- win32ole (372)
-
yaml
/ dbm (36) - zlib (12)
クラス
-
ARGF
. class (168) - Addrinfo (120)
- Array (738)
- BasicObject (36)
-
CSV
:: Row (36) - Class (12)
-
DRb
:: DRbObject (24) - Date (12)
- Enumerator (96)
-
Enumerator
:: Chain (14) -
Enumerator
:: Lazy (48) -
Enumerator
:: Yielder (24) - Fiber (12)
- GDBM (36)
- Hash (138)
- IO (60)
-
IRB
:: Context (12) - Matrix (24)
- Module (204)
-
Net
:: HTTP (24) -
Net
:: HTTPGenericRequest (12) -
Net
:: IMAP :: ResponseCode (12) -
Net
:: POP3 (24) -
Net
:: POPMail (108) -
Net
:: SMTP (32) - Object (150)
-
ObjectSpace
:: WeakMap (12) -
OpenSSL
:: ASN1 :: ObjectId (48) - OpenStruct (24)
- OptionParser (144)
- PStore (36)
- Pathname (24)
- Prime (24)
-
Prime
:: PseudoPrimeGenerator (48) -
RDoc
:: Markup (12) -
REXML
:: Element (12) -
REXML
:: Elements (24) -
REXML
:: Parent (84) - Random (36)
- Range (128)
- Regexp (24)
- SDBM (12)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (12) - String (24)
- Struct (48)
- Thread (44)
-
Thread
:: Queue (36) -
Thread
:: SizedQueue (36) - TracePoint (19)
- Tracer (12)
- UNIXSocket (12)
- Vector (36)
- WIN32OLE (36)
-
WIN32OLE
_ METHOD (60) -
WIN32OLE
_ PARAM (12) -
WIN32OLE
_ TYPE (156) -
WIN32OLE
_ TYPELIB (24) -
WIN32OLE
_ VARIABLE (84) -
YAML
:: DBM (36) -
Zlib
:: GzipWriter (12)
モジュール
- Enumerable (746)
- Kernel (52)
- Observable (12)
-
OptionParser
:: Arguable (24)
キーワード
- < (12)
- << (12)
- <= (12)
- <=> (36)
- >= (12)
- [] (108)
-
_ _ drbref (12) -
_ _ drburi (12) -
_ invoke (12) - all (36)
-
arg
_ config (12) - at (12)
- bind (24)
-
body
_ stream (12) - bsearch (48)
-
class
_ eval (24) -
class
_ exec (12) -
cofactor
_ expansion (12) - collect (60)
- component (12)
- connect (24)
-
connect
_ from (24) -
connect
_ to (24) - context (12)
- convert (12)
- cooked (12)
- cycle (24)
- data (12)
- default (36)
-
default
_ event _ sources (12) -
default
_ ole _ types (12) - delete (120)
-
delete
_ at (12) -
delete
_ if (24) -
delete
_ observer (12) - deq (24)
- detect (24)
- dig (40)
- each (182)
-
each
_ byte (24) -
each
_ char (24) -
each
_ child (24) -
each
_ line (48) -
each
_ with _ object (24) - element (12)
-
enum
_ for (48) -
event
_ interface (12) -
extend
_ object (12) - fetch (116)
-
fetch
_ values (20) - field (12)
- fill (72)
- filter (42)
-
filter
_ map (12) - find (24)
-
find
_ all (24) - first (48)
- getbyte (12)
- getc (12)
- grep (24)
-
grep
_ v (24) - guid (12)
- helpcontext (24)
- helpfile (24)
-
implemented
_ ole _ types (12) - inject (48)
-
inspect
_ mode (12) -
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ method (12) -
instance
_ variable _ get (12) - invoke (12)
-
laplace
_ expansion (12) - last (24)
- listen (24)
- ln (12)
-
long
_ name (12) - mail (36)
- map (48)
- match (48)
- max (130)
-
max
_ by (48) -
method
_ missing (12) - min (130)
-
min
_ by (48) - minmax (48)
-
minmax
_ by (24) -
module
_ eval (24) -
module
_ exec (12) - name (12)
- noecho (12)
-
ole
_ classes (12) -
ole
_ methods (12) -
ole
_ type (24) -
ole
_ typelib (12) -
ole
_ types (12) - on (144)
- open (24)
- parameters (7)
- partition (24)
- pop (84)
-
pretty
_ print (12) -
pretty
_ print _ instance _ variables (12) - progid (12)
- public (48)
- putc (12)
- rand (36)
- raw (12)
-
read
_ nonblock (12) -
recv
_ io (12) - reduce (36)
- reject (60)
-
respond
_ to? (12) -
return
_ value (12) - sample (48)
- select (72)
- shift (60)
-
short
_ name (12) -
size
_ opt _ params (12) -
size
_ params (12) - slice (36)
- slice! (36)
- sn (12)
- sort (24)
-
sort
_ by (24) -
source
_ ole _ types (12) -
src
_ type (12) - start (80)
- sum (42)
- superclass (12)
- tap (12)
- then (14)
-
thread
_ variable _ get (12) - timeout (16)
-
to
_ enum (48) -
to
_ h (14) -
to
_ s (12) -
trace
_ func (12) - transact (18)
- transaction (12)
- transfer (12)
- uniq (24)
- uniq! (24)
- value (24)
-
variable
_ kind (12) - variables (12)
- varkind (12)
- visible? (12)
-
with
_ index (24) -
with
_ object (48) -
with
_ werror (24) -
write
_ nonblock (12) - yield (12)
-
yield
_ self (16) - zip (48)
検索結果
先頭5件
-
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (9233.0) -
Enumerator.new(self, method, *args) を返します。
...//emlist[][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......end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, En... -
Object
# pretty _ print _ instance _ variables -> [String | Symbol] (9202.0) -
プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。 返されたインスタンス変数はプリティプリント時に表示されます。
プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。
返されたインスタンス変数はプリティプリント時に表示されます。
pp に表示したくないインスタンス変数がある場合にこのメソッドを再定義します。 -
Object
# then -> Enumerator (9135.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...してブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方......ソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件に......よって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self -> Enumerator (9135.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...してブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方......ソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件に......よって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# enum _ for(method = :each , *args) -> Enumerator (9133.0) -
Enumerator.new(self, method, *args) を返します。
...//emlist[][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......end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, En... -
Object
# to _ enum(method = :each , *args) -> Enumerator (9133.0) -
Enumerator.new(self, method, *args) を返します。
...//emlist[][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......end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, En... -
Object
# yield _ self -> Enumerator (9133.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。......ソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件に......よって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# pretty _ print(pp) -> () (9119.0) -
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。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......@param pp PP オブジェクトです。
//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
# respond _ to?(name , include _ all = false) -> bool (9119.0) -
オブジェクトがメソッド name を持つとき真を返します。
...されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。......private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour
list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello, true)")}
#=> Bonjour
# Guten Tag
module Template
def main
start
template_metho......# => true
# NotImplementedError が発生しているが、Rubyによる実装部のため true を返す
puts NotImplTemplateMethod.new.respond_to?(:template_method) # => true
# GNU/Linux で実行。C言語による実装部のため false を返す
puts File.respond_to?(:lchmod) # => fal... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (6453.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...だす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添......えて渡されるオブジェクト
@see Enumerable#each_with_object... -
Enumerable
# each _ with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (6423.0) -
与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。
...返します。
ブロックを省略した場合は Enumerator を返します。
@param obj 任意のオブジェクトを指定します。
//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerator#with_object...