るりまサーチ

最速Rubyリファレンスマニュアル検索!
1310件ヒット [1-100件を表示] (0.119秒)
トップページ > クエリ:i[x] > クエリ:end[x] > クエリ:<[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. matrix i
  5. csv to_i

キーワード

検索結果

<< 1 2 3 ... > >>

Module#<(other) -> bool | nil (18260.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...較では
nil を返します。

@param other 比較対象のモジュールやクラス

@raise TypeError other がクラスやモジュールではない場合に発生します。

//emlist[例][ruby]{
module Foo
end

class Bar
i
nclude Foo
end

class Baz < Bar
end

class Qux
end

p Bar < Foo #...
...=> true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}...

rinda/rinda (12036.0)

Rubyで実装されたタプルスペース(Tuple Space)を扱うためのライブラリです。

...対しては、タプルを書き込む(write)、取り出す(take)、
タプルの要素を覗き見る(read)
という操作のみが利用できます。可能な操作を限定し、定型化することで
安全な同期処理を実現します。rinda においてはタプルとは
配列も...
...rinda_ts.rb
require 'drb/drb'
require 'rinda/tuplespace'

uri = ARGV.shift
DRb.start_service(uri, Rinda::TupleSpace.new)
puts DRb.uri
DRb.thread.join


# rindas.rb
require 'drb/drb'
require 'rinda/rinda'

def do_it(v)
puts "do_it(#{v})"
v + v
end


uri = ARGV.shi...
...raise("usage: #{$0} <server_uri>")

DRb.start_service
ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, uri))

while true
r = ts.take(['sum', nil, nil])
v = do_it(r[2])
ts.write(['ans', r[1], r[2], v])
end



# rindac.rb
require 'drb/drb'
require 'rinda/rinda'

uri...

Exception#backtrace_locations -> [Thread::Backtrace::Location] (9224.0)

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

...ception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。

現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。

//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if D...
...aise "#{month} is not long month"
end


def get_exception
return begin
yield
rescue => e
e
end

end


e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get_exception'", "test.rb:15:i...
...n `<main>'"]
//}

@see Exception#backtrace...

TracePoint#instruction_sequence -> RubyVM::InstructionSequence (9224.0)

script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。

...script_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。

//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end
.enable do
eval...
...("puts 'hello'")
end

//}

@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。...

REXML::Attributes#each_attribute {|attribute| ... } -> () (9218.0)

各属性に対しブロックを呼び出します。

...ttribute オブジェクトで渡されます。

//emlist[][ruby]{
require 'rexml/document'

doc = REXML::Document.new(<<EOS)
<
root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<
a foo:att='1' bar:att='2' att='&lt;'/>
<
/root>
EOS
a = doc.get_elements("/root/a").firs...
...t

a.attributes.each_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end

# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...

絞り込み条件を変える

Zlib::Inflate#<<(string) -> self (9206.0)

Zlib::Inflate#inflate と同じように string を 展開ストリームに入力しますが、Zlib::Inflate オブジェクト そのものを返します。展開ストリームからの出力は、 出力バッファに保存されます。

...Zlib::Inflate#inflate と同じように string を
展開ストリームに入力しますが、Zlib::Inflate オブジェクト
そのものを返します。展開ストリームからの出力は、
出力バッファに保存されます。

require 'zlib'

cstr = "x\234\313\310OOUH+MOTH\3...
...15K\001\000!\251\004\276"
i
nz = Zlib::Inflate.new
i
nz << cstr[0, 10]
p inz.flush_next_out #=> "hoge fu"

i
nz << cstr[10..-1]
p inz.flush_next_out #=> "ga end"...

Gem::Dependency#<=>(other) -> Integer (9200.0)

self と other を Gem::Dependency#name の ASCII コードで比較して self が大きい時には正の整数、等しい時には 0、小さい時には負の整数を返します。

...self と other を Gem::Dependency#name の ASCII コードで比較して
self が大きい時には正の整数、等しい時には 0、小さい時には負の整数を返します。...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (9174.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...を過ぎたときは例外
Timeout::Error が発生します。

exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。

また sec が 0 もしくは nil のときは制限時間なし...
...ecution expired" になります.

例 長い計算のタイムアウト
require 'timeout'

def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end

end


t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)...
...imeout::Error
puts "timeout"
end


printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.ti...

Timeout.#timeout(sec, exception_class, message) {|i| ... } -> object (9174.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...を過ぎたときは例外
Timeout::Error が発生します。

exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。

また sec が 0 もしくは nil のときは制限時間なし...
...ecution expired" になります.

例 長い計算のタイムアウト
require 'timeout'

def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end

end


t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)...
...imeout::Error
puts "timeout"
end


printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.ti...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (9173.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...を過ぎたときは例外
Timeout::Error が発生します。

exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。

また sec が 0 もしくは nil のときは制限時間なし...
...am exception_class タイムアウトした時、発生させる例外を指定します.

例 長い計算のタイムアウト
require 'timeout'

def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end

end


t = 5
min = [ 0,...
...in
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end


printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby

require 'ti...

絞り込み条件を変える

Enumerator::Yielder#<<(object) -> () (9112.0)

Enumerator.new で使うメソッドです。

...r::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<
< に渡された値とともに繰り返されます。

//emlist[例][ruby]{
enum = Enumerator.new do |y|
y << 1
y << 2
y << 3
end


e...
...num.each do |v|
p v
end

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