種類
- インスタンスメソッド (43)
- 文書 (26)
- ライブラリ (22)
- モジュール関数 (22)
- 特異メソッド (18)
ライブラリ
- ビルトイン (54)
- benchmark (22)
-
ripper
/ lexer (7)
クラス
- Ripper (7)
-
RubyVM
:: InstructionSequence (22) -
Thread
:: Backtrace :: Location (11) - UncaughtThrowError (10)
モジュール
- Benchmark (22)
オブジェクト
- main (11)
キーワード
-
NEWS for Ruby 3
. 0 . 0 (4) -
base
_ label (22) - benchmark (11)
- bm (11)
-
cgi
/ session (11) - lex (7)
- rdoc (11)
-
ruby 1
. 8 . 4 feature (11) -
to
_ s (10) - using (11)
- リテラル (11)
検索結果
先頭5件
-
RubyVM
:: InstructionSequence # label -> String (21237.0) -
self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。
..."<main>" を返します。self を文字列から作成していた場合
は "<compiled>" を返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
# => "<compiled>"......M::InstructionSequence.compile_file を使用した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label # => "<main>"
例3:
# /tmp/method2.rb
def hello
puts "hello, world"
end......RubyVM::InstructionSequence.of(method(:hello)).label
# => "hello"
@see RubyVM::InstructionSequence#base_label... -
Thread
:: Backtrace :: Location # base _ label -> String (9247.0) -
self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。
...ocation#label から修飾を取り除いたもので構成
されます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.base_label
end
# => initialize......# new
# <main>
//}
@see Thread::Backtrace::Location#label... -
RubyVM
:: InstructionSequence # base _ label -> String (9237.0) -
self が表す命令シーケンスの基本ラベルを返します。
...ラベルを返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.base_label
# => "<compiled>"
例2: RubyVM::InstructionSequence.compile_file を使用した場合
# /tmp/me......world"
end
# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"
例3:
# /tmp/method2.rb
def hello
puts "hello, world"
end
RubyVM::InstructionSequence.of(method(:hello)).base_label
# => "hello"
@see RubyVM::InstructionSeq......uence#label... -
main
. using(module) -> self (9124.0) -
引数で指定したモジュールで定義された拡張を有効にします。
...inements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
//emlist[例][ruby]{
module Sloth
refine String do
def downcase
self
end
end
end
"ABC".downcase # => "abc"
using Sloth
"ABC".downcase # => "ABC"
//}
@see Module#refine, Module#usi... -
cgi
/ session (6078.0) -
CGI のセッション管理を行うライブラリ。
...CGI のセッション管理を行うライブラリ。
セッションとは、HTTP の一連のリクエストとレスポンスが属するべき
コンテクスト (状況) のことをいいます。
セッション管理には従来通り cgi ライブラリが提供する
クッキーを使......@cgi) # セッションはこうして生成する。
@cmd = "#{@cgi['cmd'].first}" # ruby 1.8 でも動くように(warning は出ます)
@cmd = 'start' if @cmd.empty?
@header = { "type" => "text/html", "charset" => "euc-jp" }
__send__(......>
<p>#{CGI.escapeHTML(name)}さん、さようなら</p>
<p><a href="#{CGI.escapeHTML(ENV['SCRIPT_NAME'])}">[戻る]</a></p>
</body></html>
END
}
end
end
SessionDemo.new
=== 参考URL
* http://www.shugo.net/article/webdb2/#label:13
* http://ww... -
Ripper
. lex(src , filename = & # 39;-& # 39; , lineno = 1 , raise _ errors: false) -> [[Integer , Integer] , Symbol , String , Ripper :: Lexer :: State] (3142.0) -
Ruby プログラム str をトークンに分割し、そのリストを返します。 ただし Ripper.tokenize と違い、トークンの種類と位置情報も付属します。
...Ripper.tokenize と違い、トークンの種類と位置情報も付属します。
@param src Ruby プログラムを文字列か IO オブジェクトで指定します。
@param filename src のファイル名を文字列で指定します。省略すると "-" になります。
@param lin......。
@raise SyntaxError raise_errors が true で、src に文法エラーがある場合に発生します。
//emlist[][ruby]{
require 'ripper'
pp Ripper.lex("def m(a) nil end")
# => [[[1, 0], :on_kw, "def", FNAME],
# [[1, 3], :on_sp, " ", FNAME],
# [[1, 4], :on_ident, "m", ENDFN],
#......5], :on_lparen, "(", BEG|LABEL],
# [[1, 6], :on_ident, "a", ARG],
# [[1, 7], :on_rparen, ")", ENDFN],
# [[1, 8], :on_sp, " ", BEG],
# [[1, 9], :on_kw, "nil", END],
# [[1, 12], :on_sp, " ", END],
# on_kw, "end", END
Ripper.lex("def req(true) end", raise_errors: true)
# => Syn... -
Ripper
. lex(src , filename = & # 39;-& # 39; , lineno = 1) -> [[Integer , Integer] , Symbol , String , Ripper :: Lexer :: State] (3136.0) -
Ruby プログラム str をトークンに分割し、そのリストを返します。 ただし Ripper.tokenize と違い、トークンの種類と位置情報も付属します。
...Ripper.tokenize と違い、トークンの種類と位置情報も付属します。
@param src Ruby プログラムを文字列か IO オブジェクトで指定します。
@param filename src のファイル名を文字列で指定します。省略すると "-" になります。
@param lin......す。
//emlist[][ruby]{
require 'ripper'
pp Ripper.lex("def m(a) nil end")
# => [[[1, 0], :on_kw, "def", EXPR_FNAME],
# [[1, 3], :on_sp, " ", EXPR_FNAME],
# [[1, 4], :on_ident, "m", EXPR_ENDFN],
# [[1, 5], :on_lparen, "(", EXPR_BEG|EXPR_LABEL],
# [[1, 6], :on_ident, "a", EXPR_AR......G],
# [[1, 7], :on_rparen, ")", EXPR_ENDFN],
# [[1, 8], :on_sp, " ", EXPR_BEG],
# [[1, 9], :on_kw, "nil", EXPR_END],
# [[1, 12], :on_sp, " ", EXPR_END],
# on_kw, "end", EXPR_END
//}
Ripper.lex は分割したトークンを詳しい情報とともに返します。
返り値の......emlist[][ruby]{
require 'ripper'
pp Ripper.lex("def m(a) nil end")
# => [[[1, 0], :on_kw, "def", FNAME],
# [[1, 3], :on_sp, " ", FNAME],
# [[1, 4], :on_ident, "m", ENDFN],
# [[1, 5], :on_lparen, "(", BEG|LABEL],
# [[1, 6], :on_ident, "a", ARG],
# [[1, 7], :on_rparen, ")", ENDFN]......,
# [[1, 8], :on_sp, " ", BEG],
# [[1, 9], :on_kw, "nil", END],
# [[1, 12], :on_sp, " ", END],
# on_kw, "end", END
//}
Ripper.lex は分割したトークンを詳しい情報とともに返します。
返り値の配列の要素は 4 要素の配列 (概念的にはタプル) で... -
リテラル (3108.0)
-
リテラル * num * string * backslash * exp * char * command * here * regexp * array * hash * range * symbol * percent
...リテラル
* num
* string
* backslash
* exp
* char
* command
* here
* regexp
* array
* hash
* range
* symbol
* percent
数字の1や文字列"hello world"のようにRubyのプログラムの中に直接
記述できる値の事をリテラルといいます。
===[a:n......list[][ruby]{
# 式の中に開始ラベルを書く
# method の第二引数には " ヒアドキュメント\n" が渡される
method(arg1, <<LABEL, arg2)
ヒアドキュメント
LABEL
# ヒアドキュメントをレシーバにメソッドを呼ぶ
p <<LABEL.upcase
the lower case stri......//emlist[][ruby]{
if need_define_foo
eval <<-EOS # '<<-' を使うと……
def foo
print "foo\n"
end
EOS
#↑終端行をインデントできます。
end
//}
一行に複数のヒアドキュメントを書くこともできます。
//emlist[][ruby]{
print <<FIRST, <<S......やコメントさえも書くことはできません。
//emlist[][ruby]{
if need_define_foo
eval <<-EOS # '<<-' を使うと……
def foo
print "foo\n"
end
EOS
#↑終端行をインデントできます。
end
//}
開始ラベルを `<<~識別子` のように `~` を付... -
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (397.0) -
Benchmark.#benchmark メソッドの引数を簡略化したものです。
...aram label_width ラベルの幅を指定します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm do |x|
x.report { for i in 1..n; a = "1"; end }
x.report { n.times......"1"; end }
x.report { 1.upto(n) do ; a = "1"; end }
end
#=>
#
# user system total real
# 1.033333 0.016667 1.016667 ( 0.492106)
# 1.483333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.711077)
//}
以下のようにも書けます。
//emlist[......][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm(7) do |x|
x.report("for:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end
#=>
# user system total real
# for: 1.05... -
Benchmark
. # benchmark(caption = "" , label _ width = nil , fmtstr = nil , *labels) {|rep| . . . } -> [Benchmark :: Tms] (349.0) -
Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。
...の配列を返した場合は、
それらの数値も追加の行に表示されます。
@param caption レポートの一行目に表示する文字列を指定します。
@param label_width ラベルの幅を指定します。
@param fmtstr フォーマット文字列を指定しま......m labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
=== フォーマット文字列
フォーマット文字列として以下が使用できます。
: %u
user CPU time で置き換えられます。Benchmark::Tms#utime
: %y
system CPU tim......ベルで置き換えられます(Mnemonic: n of "*n*ame")。Benchmark::Tms#label
//emlist[][ruby]{
require 'benchmark'
n = 50000
# これは
# Benchmark.bm(7, ">total:", ">avg:") do |x| ... end
# と同じ
Benchmark.benchmark(" "*7 + Benchmark::CAPTION,
7,... -
ruby 1
. 8 . 4 feature (192.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...更
# * [api]: 拡張ライブラリ API
# * [lib]: ライブラリ
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど
* 互換性のある変更
* only backward-compatibility
* 影...... if valid as a symbol name more strictly. [ruby-dev:27478]
#
# * test/ruby/test_symbol.rb: tests for [ruby-core:03573].
Symbolに適合する文字列を厳密にした。((<ruby-core:03573>)),((<ruby-dev:27478>))
1) alias :"foo" :"bar"
def bar; p "bar"; end......tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
# ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
# ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/labelframe.rb,
# ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/menu.rb,
# ext/tk/lib/tk/radiobutton.rb, ext/tk/lib/t...