ライブラリ
- English (11)
- ビルトイン (453)
- csv (22)
-
fiddle
/ import (11) -
irb
/ inspector (11) - openssl (132)
- optparse (22)
- ostruct (12)
- pathname (131)
-
rexml
/ document (11) - set (22)
-
shell
/ filter (12) - uri (22)
-
webrick
/ httpresponse (22) - win32ole (33)
- zlib (22)
クラス
- Array (44)
-
CSV
:: Row (22) -
Enumerator
:: Lazy (20) - Hash (66)
- IO (22)
-
IRB
:: Inspector (11) - Module (33)
- Object (26)
-
OpenSSL
:: PKey :: DSA (66) -
OpenSSL
:: PKey :: RSA (66) - OpenStruct (12)
- OptionParser (22)
- Pathname (131)
- Range (11)
- Regexp (11)
-
Shell
:: Filter (12) - Symbol (143)
- Thread (22)
-
Thread
:: Backtrace :: Location (22) -
URI
:: Generic (22) - UnboundMethod (11)
-
WEBrick
:: HTTPResponse (22) -
WIN32OLE
_ EVENT (11) -
WIN32OLE
_ VARIABLE (22) -
Zlib
:: GzipWriter (22)
モジュール
- Enumerable (22)
-
Fiddle
:: Importer (11) - Kernel (22)
キーワード
-
$ ERROR _ INFO (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - << (11)
- =~ (11)
- ExternalEntity (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - Numeric (11)
- [] (55)
-
add
_ trace _ func (11) -
all
_ symbols (11) - bigdecimal (11)
- bind (11)
- binread (11)
-
content
_ length (11) -
content
_ length= (11) -
def
_ inspector (11) -
each
_ entry (13) -
each
_ line (22) - empty? (8)
- export (44)
- find (22)
- grep (11)
-
grep
_ v (9) - handler= (11)
- help (11)
- inspect (22)
- irb (11)
- match (11)
- name (22)
- new (11)
- normalize (11)
- normalize! (11)
- open (22)
- opendir (22)
-
optparse
/ date (11) - owner (11)
- read (11)
- resolv (11)
- rss (11)
-
ruby 1
. 6 feature (11) -
set
_ trace _ func (22) - slice (55)
- syswrite (11)
- then (12)
-
to
_ csv (11) -
to
_ h (12) -
to
_ pem (44) -
to
_ set (22) - tracer (11)
-
transform
_ keys (17) -
transform
_ keys! (17) -
transform
_ values (16) -
transform
_ values! (16) - uniq (22)
- uniq! (22)
- write (22)
-
yield
_ self (14) - メソッド呼び出し(super・ブロック付き・yield) (9)
検索結果
先頭5件
-
irb (276.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...ons:
-f ~/.irbrc を読み込まない
-m bc モード (分数と行列の計算ができる)
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r......な記法は以下の通りです。
: %N
起動しているコマンド名(IRB::Context#irb_name)
: %m
main オブジェクト (self) を to_s した文字列
: %M
main オブジェクト (self) を inspect した文字列
: %l
文字列中のタイプを表す (", ', /, ], `]'は%......設定をまとめて設定することができます。
以下に例を示します。
$ irb
irb(main):001:0> IRB.conf[:IRB_RC] = lambda {|conf| conf.prompt_i = "> " }
=> #<Proc:0x00002a95fa3fd8@(irb):2>
irb(main):002:0> irb
>
=== irb の使用例
irb のいろいろな使用例を... -
Thread
# set _ trace _ func(pr) -> Proc | nil (273.0) -
スレッドにトレース用ハンドラを設定します。
...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", "exampl......x00007fc8de88c440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current......, #<Binding:0x00007fc8de967798>, Thread]
# => ["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... -
irb (270.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...s:
-f ~/.irbrc を読み込まない
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r と同じ
-I ruby -I と同じ
-U ruby -U......な記法は以下の通りです。
: %N
起動しているコマンド名(IRB::Context#irb_name)
: %m
main オブジェクト (self) を to_s した文字列
: %M
main オブジェクト (self) を inspect した文字列
: %l
文字列中のタイプを表す (", ', /, ], `]'は%......設定をまとめて設定することができます。
以下に例を示します。
$ irb
irb(main):001:0> IRB.conf[:IRB_RC] = lambda {|conf| conf.prompt_i = "> " }
=> #<Proc:0x00002a95fa3fd8@(irb):2>
irb(main):002:0> irb
>
=== irb の使用例
irb のいろいろな使用例を... -
WEBrick
:: HTTPResponse # content _ length -> Integer | nil (259.0) -
Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
...Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
: body が String オブジェクトである場合
content_length の値が nil のとき Content-Length ヘッダには
body のサイズが使われます。nil でないとき body の実......同じかどうかの検証は行われません。
: body が IO オブジェクトである場合
content_length の値が nil のとき Content-Length ヘッダはレスポンスに含まれず、IO から全てを読み込ん
でそれをエンティティボディとします。nil でな......エンティティボディとします。
また 2616 4.4 で定められた Content-Length ヘッダを送ってはいけない場合に当てはまる時には
content_length の値は無視され Content-Length ヘッダはレスポンスに含まれません。
@param len ヘッダの値... -
Pathname
# each _ entry {|pathname| . . . } -> nil (239.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathna......Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathna... -
Object
# then {|x| . . . } -> object (238.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ext.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
requi......re 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件に... -
Object
# yield _ self {|x| . . . } -> object (238.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ng".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'j......son'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあ......ext.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
requi......re 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件に... -
Pathname
# each _ line(*args) {|line| . . . } -> nil (235.0) -
IO.foreach(self.to_s, *args, &block) と同じです。
...IO.foreach(self.to_s, *args, &block) と同じです。
//emlist[例][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}
//emlist[例 ブロックを指定][ruby]{
require "pathname"
IO.write("tes......ne2,\nline3\n")
Pathname("testfile").each_line {|f| p f }
# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}
//emlist[例 limit を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }
# => "line"
# => "1\n"
# => "line"
# =>......"2,\n"
# => "line"
# => "3\n"
//}
//emlist[例 sep を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }
# => "line1\nline2,"
# => "\nline3\n"
//}
@see IO.foreach... -
Hash
# transform _ keys {|key| . . . } -> Hash (225.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...ません。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(&:to_s) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2......by]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }... -
Array
# uniq {|item| . . . } -> Array (222.0) -
uniq は配列から重複した要素を取り除いた新しい配列を返します。 uniq! は削除を破壊的に行い、削除が行われた場合は self を、 そうでなければnil を返します。
...重複した要素を取り除いた
配列を返します。
//emlist[例][ruby]{
p [1, 3, 2, "2", "3"].uniq # => [1, 3, 2, "2", "3"]
p [1, 3, 2, "2", "3"].uniq { |n| n.to_s } # => [1, 3, 2]
//}
要素を先頭から辿っていき、最初に出現したものが残ります。... -
Array
# uniq! -> self | nil (222.0) -
uniq は配列から重複した要素を取り除いた新しい配列を返します。 uniq! は削除を破壊的に行い、削除が行われた場合は self を、 そうでなければnil を返します。
...重複した要素を取り除いた
配列を返します。
//emlist[例][ruby]{
p [1, 3, 2, "2", "3"].uniq # => [1, 3, 2, "2", "3"]
p [1, 3, 2, "2", "3"].uniq { |n| n.to_s } # => [1, 3, 2]
//}
要素を先頭から辿っていき、最初に出現したものが残ります。... -
Array
# uniq! {|item| . . . } -> self | nil (222.0) -
uniq は配列から重複した要素を取り除いた新しい配列を返します。 uniq! は削除を破壊的に行い、削除が行われた場合は self を、 そうでなければnil を返します。
...重複した要素を取り除いた
配列を返します。
//emlist[例][ruby]{
p [1, 3, 2, "2", "3"].uniq # => [1, 3, 2, "2", "3"]
p [1, 3, 2, "2", "3"].uniq { |n| n.to_s } # => [1, 3, 2]
//}
要素を先頭から辿っていき、最初に出現したものが残ります。...