ライブラリ
- ビルトイン (64)
-
net
/ http (7) - prettyprint (11)
-
shell
/ command-processor (6) -
webrick
/ httpproxy (11)
クラス
- Method (12)
- PrettyPrint (11)
-
Process
:: Status (11) -
Shell
:: CommandProcessor (6) -
WEBrick
:: HTTPProxyServer (11)
モジュール
- Process (33)
-
RubyVM
:: AbstractSyntaxTree (8)
キーワード
- << (6)
- >> (6)
-
CLOCK
_ MONOTONIC _ RAW _ APPROX (11) -
CLOCK
_ UPTIME _ RAW _ APPROX (11) - HTTPProcessing (7)
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (4) - append (6)
- format (11)
- irb (11)
- new (11)
- of (8)
- ppid (11)
- stopped? (11)
検索結果
先頭5件
-
pp (38144.0)
-
オブジェクトなどを見やすく出力するためのライブラリです。
...このライブラリを require すると Kernel.#pp が定義されます。
Kernel.#p のかわりに Kernel.#pp を使うことにより、
適切にインデントと改行された分かりやすい出力を得ることが出来ます。
pp ライブラリは、ユーザがあたらしく定......うに作られていますので、Kernel.#pp を使う上で余計な作業をする
必要はありません。
=== どちらが読みやすいでしょうか?
p による pretty-print されてない出力:
#<PP:0x81a0d10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@......], @singleline_width=1>, #
<PrettyPrint::Text:0x81a0a7c @tail=0, @width=1, @text=",">, #<PrettyPrint::Break
able:0x81a0a2c @group=2, @gensace=#<Proc:0x81a0cc0>, @newline="\n", @indent=1, @
tail=2, @sep=" ", @width=1>, #<PrettyPrint::Group:0x81a09c8 @group=2, @tail=1, @
buf=[#<PrettyPrint::Te......などを見やすく出力するためのライブラリです。
pp ライブラリは、ユーザがあたらしく定義したクラスに対しても見やすい表示を
するように作られていますので、Kernel.#pp を使う上で余計な作業をする
必要はありません。......=== どちらが読みやすいでしょうか?
p による pretty-print されてない出力:
#<PP:0x81a0d10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@buf=#<PrettyPrint::Group:0x81a0c98 @group=0, @tail=0, @buf=[#<PrettyPrint::Gro
up:0x81a0ba8 @group=1, @tail=0, @... -
Net
:: HTTPProcessing (12000.0) -
HTTP レスポンス 102 (Processing) を表現するクラスです。
...HTTP レスポンス 102 (Processing) を表現するクラスです。
詳しくは 2518 を見てください。... -
Shell
:: CommandProcessor # append(to , filter) -> Shell :: AppendFile | Shell :: AppendIO (9300.0) -
@todo
@todo
@param to 文字列か IO を指定します。
@param filter Shell::Filter のインスタンスを指定します。 -
Process
. # ppid -> Integer (9100.0) -
親プロセスのプロセス ID を返します。UNIX では実際の親プロセスが終 了した後は ppid は 1 (initの pid)になります。
...親プロセスのプロセス ID を返します。UNIX では実際の親プロセスが終
了した後は ppid は 1 (initの pid)になります。
@see getppid(2)... -
Process
:: CLOCK _ MONOTONIC _ RAW _ APPROX -> Integer (9100.0) -
Process.#clock_gettime で使われます。
...
Process.#clock_gettime で使われます。
システムによっては定義されていません。... -
Process
:: CLOCK _ UPTIME _ RAW _ APPROX -> Integer (9100.0) -
Process.#clock_gettime で使われます。
...
Process.#clock_gettime で使われます。
システムによっては定義されていません。... -
Process
:: Status # stopped? -> bool (9100.0) -
プロセスが現在停止(終了ではない)している場合に真を返します。 Process.#waitpid に Process::WUNTRACED フラグを設定した 場合にだけ真になりえます。
...プロセスが現在停止(終了ではない)している場合に真を返します。
Process.#waitpid に Process::WUNTRACED フラグを設定した
場合にだけ真になりえます。... -
WEBrick
:: HTTPProxyServer . new(config , default = WEBrick :: Config :: HTTP) -> WEBrick :: HTTPProxyServer (3160.0) -
プロクシオブジェクトを生成して返します。
...oxyAuthProc
プロクシ認証を行う Proc オブジェクトを指定します。この proc は
WEBrick::HTTPResponse オブジェクトと WEBrick::HTTPRequest オブジェクトを引数として
proc.call(req, res) のように呼ばれます。
認証に失敗した場合 proc は適......ck/httpproxy'
auth_proc = proc{|req, res|
unless c = req['proxy-authorization']
res['Proxy-Authenticate'] = 'Basic realm="WEBrick Proxy"'
raise WEBrick::HTTPStatus::ProxyAuthenticationRequired
else
# 略
end
}
s = WEBrick::HTTPProxyServer.new(ProxyAuthProc: auth_proc, Port......ーバからの内容を処理する Proc オブジェクトを指定します。
レスポンスの内容を書き換えたりする事が出来ます。WEBrick::HTTPResponse オブジェクトと
WEBrick::HTTPRequest オブジェクトを引数として proc.call(req, res) のように呼ば... -
RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node (170.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。
@param proc...... Procもしくはメソッドオブジェクトを指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を指定すると、 Node#token が利用......す。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
def hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxT... -
RubyVM
:: AbstractSyntaxTree . of(proc , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node (170.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。
@param proc...... Procもしくはメソッドオブジェクトを指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を指定すると、 Node#token が利用......す。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
def hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxT... -
RubyVM
:: AbstractSyntaxTree . of(proc) -> RubyVM :: AbstractSyntaxTree :: Node (169.0) -
引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。
このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。
@param proc...... Procもしくはメソッドオブジェクトを指定します。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))
d......ef hello
puts "hello, world"
end
pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: n... -
Method
# <<(callable) -> Proc (153.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します......。
Method#>> とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # =>......uby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
Method
# >>(callable) -> Proc (153.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します......。
Method#<< とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 * 3) + (3 * 3)
p (method(:f) >> method(:g)).call(3) # =>......uby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = File.method(:read) >> WordScanner >> method(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
PrettyPrint
. format(output = & # 39;& # 39; , maxwidth = 79 , newline = "\n" , genspace = lambda{|n| & # 39; & # 39; * n}) {|pp| . . . } -> object (119.0) -
PrettyPrint オブジェクトを生成し、それを引数としてブロックを実行します。 与えられた output を返します。
...きをするもので簡便のために用意されています。
//emlist[][ruby]{
require 'prettyprint'
begin
pp = PrettyPrint.new(output, maxwidth, newline, &genspace)
...
pp.flush
output
end
//}
@param output 出力先を指定します。output は << メソッドを持っていな......際の出力幅は maxwidth を越えることがあります。
@param newline 改行に使われます。
@param genspace 空白の生成に使われる Proc オブジェクトを指定します。
生成したい空白の幅を表す整数を引数として呼ばれます。...