るりまサーチ

最速Rubyリファレンスマニュアル検索!
48件ヒット [1-48件を表示] (0.162秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > クエリ:String[x] > クエリ:ruby[x] > クエリ:string[x] > クエリ:binread[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rubygems/defaults ruby_engine
  5. rake ruby

ライブラリ

クラス

キーワード

検索結果

Pathname#binread(*args) -> String | nil (21455.0)

IO.binread(self.to_s, *args)と同じです。

...IO.binread(self.to_s, *args)と同じです。

//emlist[例][ruby]{
require "pathname"

pathname = Pathname("testfile")
pathname.binread # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
pathname.binread(20) # => "This is line one\nThi"
pathname.binread(2...
...0, 10) # => "ne one\nThis is line "
//}

@see IO.binread...

IO.binread(path, length = nil, offset = 0) -> String | nil (18533.0)

path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。

...path で指定したファイルを open し、offset の所まで seek し、
length バイト読み込みます。

Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。

length を省略するとファイルの末尾まで読み込み...
...IT" です。

//emlist[例][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...\n")
IO.binread("testfile") # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.binread("testfile", 20) # => "This is line one\nT...
...hi"
IO.binread("testfile", 20, 10) # => "ne one\nThis is line "
//}

@see IO.read...

IO.binwrite(path, string, offset=nil) -> Integer (6470.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

ファイルを開くときの mode が "rb:ASCII-8BIT" で、バイナリモードが有効
である点以外は IO.write と同じです。

Kernel.#open と同様 path の先頭が "|" ならば、"|" に...
...offset を指定するとその位置までシークします。

offset を指定しないと、書き込みの末尾でファイルを
切り捨てます。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置

//emlist[例][ruby]{
# 8x...
...ADklEQVQIW2P4DwUMlDEA98A/wTjP
QBoAAAAASUVORK5CYII='.unpack('m').first

# 期待する先頭16バイトの16進ダンプ: どの環境でも同じ。
puts png[0...16].unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52

# binwriteを使用した場合:...

Marshal フォーマット (3648.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...述しています。

=== nil, true, false

それぞれ、'0', 'T', 'F' になります。

//emlist[][ruby]{
p Marshal.dump(nil).unpack1("x2 a*") # => "0"
p Marshal.dump(true).unpack1("x2 a*") # => "T"
p Marshal.dump(false).unpack1("x2 a*") # => "F"
//}

Ruby
2.1 以前では、インスタン...
...ス変数を設定しても dump されません。
Ruby
2.2 以降は freeze されているので、インスタンス変数は設定できません。

=== Fixnum

'i' に続けて Fixnum を表すデータ構造が続きます。

数値部分を表す形式(これは Fixnum に限らず他の...
...形式 1

数値 n に対して

//emlist{
n == 0: 0
0 < n < 123: n + 5
-124 < n < 0: n - 5
//}

という数値(1 byte)を格納します。5 を足したり引いたりするのは下記の
形式 2 との区別のためです。

//emlist[例][ruby]{
p Marshal.dump(-1).unpack1("x2 a*") #...