るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. zlib end

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

StopIteration#result -> object (18120.0)

この例外オブジェクトを発生させる原因となったメソッド等の返り値を返します。

...ect = Object.new
def object.each
yield :yield1
yield :yield2
:each_returned
end


enumerator = object.to_enum

p enumerator.next #=> :yield1
p enumerator.next #=> :yield2

begin
enumerator.next
rescue StopIteration => error
p error.result #=> :each_returned
end
...

Gem::DependencyList#spec_predecessors -> Hash (3007.0)

@todo ???

...@todo ???

Return a hash of predecessors. <tt>result[spec]</tt> is an
Array of gemspecs that have a dependency satisfied by the named
spec....

FileUtils#sh(*cmd) {|result, status| ... } (114.0)

与えられたコマンドを実行します。

...参照してください。


例:
sh %{ls -ltr}

sh 'ls', 'file with spaces'

# check exit status after command runs
sh %{grep pattern file} do |ok, res|
if ! ok
puts "pattern not found (status = #{res.exitstatus})"
end

end


@see Kernel.#exec, Kernel.#system...

CSV#force_quotes? -> bool (37.0)

出力される全てのフィールドがクオートされる場合は、真を返します。

..."row1_2"]]
result
= CSV.generate(force_quotes: false) do |csv|
rows.each { |row| csv << row }
csv.force_quotes? # => false
end

print result

# => header1,header2
# "row1_1,",row1_2
//}

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

rows = [["header1", "header2"], ["row1_1,", "row1_2"]]
result
= CSV.gen...
...erate(force_quotes: true) do |csv|
rows.each { |row| csv << row }
csv.force_quotes? # => true
end

print result

# => true
# => "header1","header2"
# "row1_1,","row1_2"
//}

@see CSV.new...

CSV#write_headers? -> bool (37.0)

ヘッダを出力先に書き込む場合は真を返します。 そうでない場合は偽を返します。

...1", "row1_2"]
result
= CSV.generate(headers: header, write_headers: false) do |csv|
csv.write_headers? # => false
csv << row
end

result
# => "row1_1,row1_2\n"

result
= CSV.generate(headers: header, write_headers: true) do |csv|
csv.write_headers? # => true
csv << row
end

result
# => "header...

絞り込み条件を変える

Object#_dump(limit) -> String (37.0)

Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。

...べきです。

//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end

def _dump(limit)
Marshal.dump(@foo, limit)
end

def self._load(obj)
p obj
Foo.new(Marshal.load(obj))
end

end

foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf234 @foo=["f...
..."bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bu:\bFoo\023\004\b[\a\"\bfoo\"\bbar"
result
= Marshal.load(dms) #=> "\004\b[\a\"\bfoo\"\bbar" # self._load の引数
p result #=> #<Foo:0xbaf07c @foo=["foo", "bar"]>
//}

インスタンス変数の情報は普...

Object#marshal_dump -> object (37.0)

Marshal.#dump を制御するメソッドです。

...= arg
end

def marshal_dump
@foo
end

def marshal_load(obj)
p obj
@foo = obj
end

end

foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:\bFoo[\a\"\bfoo\"\bbar"
result
= M...
...arshal.load(dms) #=> ["foo", "bar"] # marshal_load の引数
p result #=> #<Foo:0xbaf2ac @foo=["foo", "bar"]>
//}

インスタンス変数の情報は普通マーシャルデータに含まれるので、
上例のように marshal_dump を定義する必要はありません
(た...

Mutex#synchronize { ... } -> object (31.0)

mutex をロックし、ブロックを実行します。実行後に必ず mutex のロックを解放します。

...また、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。

//emlist[例][ruby]{
m = Mutex.new
result
= m.synchronize do
m.locked? # => true
# critical part
"result"
end

m.locked? # => false
result
# => "result"
//}...

Object#===(other) -> bool (31.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...age = 12
# (0..2).===(12), (3..6).===(12), ... が実行される
result
=
case age
when 0 .. 2
"baby"
when 3 .. 6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end


puts result #=> "child"

def check arg
case arg
when /ruby(?!\s*on\s*ra...
...ils)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end

end


puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@see Object#=...

Thread::Mutex#synchronize { ... } -> object (31.0)

mutex をロックし、ブロックを実行します。実行後に必ず mutex のロックを解放します。

...また、Signal.#trap に指定したハンドラ内で実行
した場合に発生します。

//emlist[例][ruby]{
m = Mutex.new
result
= m.synchronize do
m.locked? # => true
# critical part
"result"
end

m.locked? # => false
result
# => "result"
//}...

絞り込み条件を変える

<< 1 2 > >>