別のキーワード
種類
- 文書 (59)
- 特異メソッド (44)
- ライブラリ (33)
- インスタンスメソッド (22)
- 変数 (11)
モジュール
- Enumerable (11)
- Kernel (11)
キーワード
-
$ DEFAULT _ OUTPUT (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 3
. 0 . 0 (4) - Rubyの起動 (11)
- chunk (11)
- irb (11)
- open (44)
- rake (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) - tsort (11)
- クラス/メソッドの定義 (11)
検索結果
-
CGI
# print(*strings) (18125.0) -
@todo
...@todo
引数の文字列を標準出力に出力します。
cgi.print は $DEFAULT_OUTPUT.print と等価です。
例:
cgi = CGI.new
cgi.print "This line is a part of content body.\r\n"... -
Kernel
$ $ DEFAULT _ OUTPUT -> IO (6131.0) -
$> の別名
...$> の別名
require "English"
dout = $DEFAULT_OUTPUT.dup
$DEFAULT_OUTPUT.reopen("out.txt", "w")
print "foo"
$DEFAULT_OUTPUT.close
$DEFAULT_OUTPUT = dout
p "bar" # => bar
p File.read("out.txt") #=> foo... -
Rubyの起動 (174.0)
-
Rubyの起動 * cmd_option * shebang
...Encoding.default_internal は nil になります。また、:エンコーディ
ング のように外部エンコーディングを省略した場合は内部エンコーディング
のみを変更します。
//emlist{
# 変更しない場合
$ ruby -e 'p Encoding.default_external; p En......ding.default_external; p Encoding.default_internal'
#<Encoding:EUC-JP>
nil
$ ruby --encoding EUC-JP -e 'p Encoding.default_external; p Encoding.default_internal'
#<Encoding:EUC-JP>
nil
# 内部エンコーディングをWindows-31Jにする場合
$ ruby -E :Windows-31J -e 'p Encoding.default_ext......はRubyの配列変数($:)に追加されます。
: -l
行末の自動処理を行います。まず、$\ を
$/ と同じ値に設定し, printでの出力
時に改行を付加するようにします。それから, -n
フラグまたは-pフラグが指定されていると
gets... -
NEWS for Ruby 3
. 0 . 0 (78.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...l:label-TypeProf] is experimentally bundled. It is a
type analysis tool for Ruby programs.
* Deprecation warnings are no longer shown by default (since Ruby 2.7.2).
Turn them on with `-W:deprecated` (or with `-w` to show other warnings too).
16345
* `$SAFE` and `$KCODE` are now n......it may now invoke the `block`/`unblock` scheduler hooks in a non-blocking context. 16786
* Dir
* Dir.glob and Dir.[] now sort the results by default, and accept the `sort:` keyword option. 8709
* ENV
* ENV.except has been added, which returns a hash excluding the given keys and their va......onse, and Net::HTTP.get_print can take the request headers as a Hash in the second argument when the first argument is a URI. 16686
* Net::SMTP
* Add SNI support.
* Net::SMTP.start arguments are keyword arguments.
* TLS should not check the host name by default.
* OpenStruct
* I... -
irb (60.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...され、結果が表示されます。
irb(main):001:0> 1+2
3
irb(main):002:0> class Foo
irb(main):003:1> def foo
irb(main):004:2> print 1
irb(main):005:2> end
irb(main):006:1> end
:foo
irb(main):007:0>
また irb コマンドは readline ライブラリにも対応し......ode
プロンプトモードを切り替える。現在定義されているプ
ロンプトモードは、default/simple/xmp/inf-ruby。
--inf-ruby-mode emacsのinf-ruby-mode 用のプロンプト表示を行なう。
特に指定が......il
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:MATH_MODE] = false
IRB.conf[:PROMPT] = {....}
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TR......e
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:PROMPT] = {....}
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TR......e
IRB.conf[:INSPECT_MODE] = nil
IRB.conf[:IRB_NAME] = "irb"
IRB.conf[:IRB_RC] = nil
IRB.conf[:PROMPT] = {....}
IRB.conf[:PROMPT_MODE] = :DEFAULT
IRB.conf[:SINGLE_IRB] = false
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_T... -
クラス/メソッドの定義 (42.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...list[例][ruby]{
def fact(n)
if n == 1 then
1
else
n * fact(n-1)
end
end
//}
文法:
def メソッド名 ['(' [arg0 ['=' default0]] ... [',' '*' rest_args [, post ...]] [',' key1: [val1]] ... [',' '**'kwrest] [',' '&' block_arg]`)']
式.. (body)
[rescu......][ruby]{
def foo(cnt, &block_arg)
cnt.times { block_arg.call } # ブロックに収まったProcオブジェクトはcallで実行
end
foo(3) { print "Ruby! " } #=> Ruby! Ruby! Ruby!
//}
メソッド定義において、仮引数はその種類毎に以下の順序でしか指定すること
は......foo
print "foo\n"
end
//}
は未定義メソッドの呼び出しで例外 NameError を発生させます。
===[a:singleton_method] 特異メソッド定義
//emlist[例][ruby]{
def foo.test
print "this is foo\n"
end
//}
文法:
def 式 `.' 識別子 [`(' [引数 [`=' default]]... -
ruby 1
. 8 . 3 feature (30.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...: URI::HTTP#proxy_open [lib][new]
(({:http_basic_authentication})) オプションの追加
((<ruby-core:4416>))
: OpenSSL::X509::Store#set_default_paths [lib][new]
追加 ((<ruby-dev:25670>))
=== 2005-02-06
: Resolv::DNS::Resource::TXT#strings [lib] [new]
: Resolv::DNS::Message::MessageE......として
ruby 1.8.3 に IO#((<IO/readpartial>)) が追加されました。
((<ruby-dev:25430>)) ((<ruby-dev:25443>))
$ ruby -e 'sleep 1; print "hoge"' | ruby-1.8.2 -rio/nonblock -we '
io = IO.open(0)
io.no......p io.read(4)'
-e:4:in `read': Resource temporarily unavailable (Errno::EAGAIN)
from -e:4
$ ruby -e 'sleep 1; print "hoge"' | ruby-1.8.3 -rio/nonblock -we '
io = IO.open(0)
io.no... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (24.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...merge は、hash.dup.update と同じ。
Hash#merge! は、Hash#update の別名 ((<ruby-talk:59777>)), ((<ruby-dev:19463>))
: ((<Hash#default_proc|Hash/default_proc>)) [new]
追加 ((<ruby-dev:17966>))
=== IO
: ((<IO/IO.sysopen>)) [new]
: ((<Socket#sysaccept|Socket/sysaccept>)) [new]
: ((<T......み込み関数/sprintf>)) [new]
"%p" が追加されました。inspect の結果が利用されます。((<RCR#69>))
: ((<組み込み関数/trap>)) [compat]
あるシグナルに対して、SIG_DFL や SIG_IGN が割り当てられていた場合、
文字列 "DEFAULT" や "IGNORE" を......e Twister|URL:http://www.math.keio.ac.jp/~matumoto/mt.html>))
を使用するようになりました。
: ((<組み込み関数/sprintf>))('%u') [compat]
sprintf の '%u' で、最上位ビットの繰り返しをあらわす ".." は、付加
されないようになりました。((<ruby... -
ruby 1
. 6 feature (24.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...合が修正されたのだそうです。
((<ruby-win32:273>))
: 2002-08-12 Hash#==
Hash オブジェクトはデフォルト値 (((<Hash/default>))) も == で等しい
ときに等しいとみなされるようになりました。
p Hash.new("foo") == Hash.new("bar")
=>......1.6.7 (2002-07-30) [i586-linux]
: 2002-06-03 sprintf()
"%d" で引数を整数にするときに、((<組み込み関数/Integer>)) と同じ規則を
使用するようになりました。
p sprintf("%d", nil)
=> -:1:in `sprintf': no implicit conversion from nil (TypeError)......ソッドの戻り値
以下のメソッドの戻り値が正しくなりました。
((<ruby-bugs-ja:PR#182>)), ((<rubyist:1016>))
* Hash#default= が右辺を返すようになった(以前は self を返していた)。
* Dir#pos= が右辺を返すようになった(以前は self を... -
Enumerable
# chunk {|elt| . . . } -> Enumerator (18.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
...# "\n"]
# ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n",
# "\n",
# "* README, README.ja: Add a note about default C flags.\n",
# "\n"]
# ...
//}
テキストを空行で区切られた段落に分けたい場合にも nil が使えます。
//emlist[......A[A-Z][A-Za-z0-9_]+\#/
open(filename) {|f|
f.chunk {|line| pat =~ line ? $& : :_alone }.each {|key, lines|
if key != :_alone
print lines.sort.join('')
else
print lines.join('')
end
}
}
//}
@raise RuntimeError 予約されている値を用いた場合に発生します...