44件ヒット
[1-44件を表示]
(0.012秒)
別のキーワード
ライブラリ
- ビルトイン (44)
キーワード
- binmode (11)
- binmode? (11)
-
inplace
_ mode (11) -
inplace
_ mode= (11)
検索結果
先頭4件
-
ARGF
. class # inplace _ mode -> String | nil (6126.0) -
c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。
...Ruby 起動時の -i オプション や ARGF.class#inplace_mode= で設定します。
例:
# $ echo "test" > test.txt
# $ ruby -i.bak test.rb test.txt
# $ cat test.txt # => "TEST"
# $ cat test.txt.bak # => "test"
# test.rb
ARGF.inplace_mode # => ".bak"
ARGF.each......ine {|e|print e.upcase} # => "TEST"
例:
# $ echo "test" > test.txt
# $ ruby test.rb test.txt
# $ cat test.txt # => "test"
# test.rb
ARGF.inplace_mode # => nil
ARGF.each_line {|e|print e.upcase} # => "TEST"
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode=... -
ARGF
. class # inplace _ mode=(ext) (6114.0) -
c:ARGF#inplace時にバックアップファイルに付加する拡張子を設定します。 ピリオドも含めて指定する必要があります。
...$ ruby argf.rb file.txt
---- argf.rb ----
# 引数のファイル中の各行の最初の "foo" を "bar" で置き換える
ARGF.inplace_mode = '.bak'
ARGF.lines do |line|
print line.sub("foo","bar")
end
---- -i オプションを使う場合 ----
$ ruby -i.bak -p -e '$_.sub......!("foo","bar")' file.txt
---- -i オプションを使う場合その2 ----
$ ruby -i.bak -n -e 'print $_.sub("foo","bar")' file.txt
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode... -
ARGF
. class # binmode -> self (6101.0) -
self をバイナリモードにします。一度バイナリモードになった後は非バイナリ モードに戻る事はできません。
...test1.png + test2.png = 292B
# $ ruby test.rb test1.png test2.png
ARGF.binmode
ARGF.read.size # => 292
例:
# test1.png - 164B
# test2.png - 128B
# test1.png + test2.png = 292B
# $ ruby test.rb test1.png test2.png
ARGF.read.size # => 290
@see IO#binmode, ARGF.class#binmode?... -
ARGF
. class # binmode? -> bool (6101.0) -
ARGF の入力ストリームがバイナリモードなら true を返します。 そうでない場合、false を返します。
...ムがバイナリモードなら true を返します。
そうでない場合、false を返します。
バイナリモードにするためには ARGF.class#binmode を使用します。
ARGF.binmode? # => false
ARGF.binmode
ARGF.binmode? # => true
@see IO#binmode?, ARGF.class#binmode...