るりまサーチ

最速Rubyリファレンスマニュアル検索!
290件ヒット [1-100件を表示] (0.088秒)

別のキーワード

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

クラス

キーワード

検索結果

<< 1 2 3 > >>

IO#write(*str) -> Integer (18158.0)

IOポートに対して str を出力します。str が文字列でなけ れば to_s による文字列化を試みます。 実際に出力できたバイト数を返します。

...れば to_s による文字列化を試みます。
実際に出力できたバイト数を返します。

IO#syswrite を除く全ての出力メソッドは、最終的に
"write" という名のメソッドを呼び出すので、このメソッドを置き換える
ことで出力関数の挙...
...発生します。

//emlist[例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is") # => 7
end

File.read("textfile") # => "This is"
//}
//emlist[複数引数の例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is", " a test\n") # => 15
end

File.read("textfile")...

IO#write(str) -> Integer (18134.0)

IOポートに対して str を出力します。str が文字列でなけ れば to_s による文字列化を試みます。 実際に出力できたバイト数を返します。

...れば to_s による文字列化を試みます。
実際に出力できたバイト数を返します。

IO#syswrite を除く全ての出力メソッドは、最終的に
"write" という名のメソッドを呼び出すので、このメソッドを置き換える
ことで出力関数の挙...
...@raise IOError 自身が書き込み用にオープンされていなければ発生します。

@raise Errno::EXXX 出力に失敗した場合に発生します。

//emlist[例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is") # => 7
end

File.read("textfile") # => "This is"
//}...

Module#attr_writer(*name) -> [Symbol] (6139.0)

インスタンス変数 name への書き込みメソッド (name=) を定義します。

...例][ruby]{
class User
attr_writer :name # => [:name=]
# 複数の名前を渡すこともできる
attr_writer :id, :age # => [:id=, :age=]
end

//}

このメソッドで定義されるメソッドの定義は以下の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end

//}...

IO#syswrite(string) -> Integer (6137.0)

write(2) を用いて string を出力します。 string が文字列でなければ to_s による文字列化を試みます。 実際に出力できたバイト数を返します。

...
write
(2) を用いて string を出力します。
string が文字列でなければ to_s による文字列化を試みます。
実際に出力できたバイト数を返します。

stdio を経由しないので他の出力メソッドと混用すると思わぬ動作
をすることがあり...
...込み用にオープンされていなければ発生します。

@raise Errno::EXXX 出力に失敗した場合に発生します。

//emlist[例][ruby]{
File.open("testfile", "w+") do |f|
f.syswrite("ABCDE") # => 5
f.syswrite(:ABC) # => 3
end

File.read("testfile") # => "ABCDEABC"
//}...

IO#close_write -> nil (6128.0)

書き込み用の IO を close します。

...ンされていなければ発生します。

@raise Errno::EXXX close に失敗した場合に発生します。

//emlist[例][ruby]{
f = IO.popen("/bin/sh","r+") do |f|
f.close_write
# f.print "nowhere" # => IOError: not opened for writing
end

//}

@see IO#close, IO#closed?, IO#close_read...

絞り込み条件を変える

IO#pwrite(string, offset) -> Integer (6127.0)

stringをoffsetの位置にpwrite()システムコールを使って書き込みます。

...stringをoffsetの位置にpwrite()システムコールを使って書き込みます。

IO#seekとIO#writeの組み合わせと比べて、アトミックな操作に
なるという点が優れていて、複数スレッド/プロセスから同じIOオブジェクトを
様々な位置から読...
...敗した場合に発生します。
@raise NotImplementedError システムコールがサポートされていない OS で発生します。

//emlist[例][ruby]{
File.open("testfile", "w") do |f|
f.pwrite("ABCDEF", 3) # => 6
end


File.read("testfile") # => "\u0000\u0000\u0000ABCDEF"
//}...

Module#attr_writer(*name) -> nil (6121.0)

インスタンス変数 name への書き込みメソッド (name=) を定義します。

...タンス変数 name への書き込みメソッド (name=) を定義します。


このメソッドで定義されるメソッドの定義は以下の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end

//}

@param name String または Symbol を 1 つ以上指定します。...

Method#<<(callable) -> Proc (81.0)

self と引数を合成した Proc を返します。

...//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) # => 36
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
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 (81.0)

self と引数を合成した Proc を返します。

...//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) # => 18
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
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#>>...

Proc#>>(callable) -> Proc (69.0)

self と引数を合成した Proc を返します。

...ト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 * 3) + (3 * 3)
p (f >> g).call(3) # => 18
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)...
...Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@see Method#<<, Method#>>...

絞り込み条件を変える

Proc#<<(callable) -> Proc (57.0)

self と引数を合成した Proc を返します。

...ト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}

//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end

end


File.write('testfile', <<~TEXT)...
...Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}

@see Method#<<, Method#>>...

Object#display(out = $stdout) -> nil (45.0)

オブジェクトを out に出力します。

...います。

//emlist[][ruby]{
class Object
def display(out = $stdout)
out.write self
nil
end

end

//}

@param out 出力先のIOオブジェクトです。指定しない場合は標準出力に出力されます。
@return nil を返します。

//emlist[][ruby]{
Object.new.display #=...

IO#set_encoding_by_bom -> Encoding | nil (39.0)

BOM から IO のエンコーディングを設定します。

...す。

//emlist[例][ruby]{
File.write("bom.txt", "\u{FEFF}abc")
File.open("bom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> #<Encoding:UTF-8>
str = io.read
p str #=> "abc"
p str.encoding #=> #<Encoding:UTF-8>
end


File.write("nobom.txt", "abc")...
...File.open("nobom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> nil
end

//}...
<< 1 2 3 > >>