るりまサーチ

最速Rubyリファレンスマニュアル検索!
650件ヒット [101-200件を表示] (0.031秒)
トップページ > クエリ:end[x] > 種類:ライブラリ[x]

別のキーワード

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

検索結果

<< < 1 2 3 4 ... > >>

tsort (73.0)

tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。

...]{
require 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end

end


{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]

{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
#=> [[4], [2, 3], [1...
...tsort'

class Make
def initialize
@dep = {}
@dep.default = []
end


def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] = inputs
end


def build(target)
each_strongly_connected_component_from(target...
...) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end

n = ns.first
if Array === n
outputs, inputs, block = n
inputs_time = inputs.map {|f| File.mtime f}.max
beg...

bigdecimal (67.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...0
for i in (1..10000)
sum = sum + 0.0001
end

print sum # => 0.9999999999999062
//}

//emlist[例2: 0.0001 を 10000 回足す場合。(BigDecimal)][ruby]{
require 'bigdecimal'

sum = BigDecimal("0")
for i in (1..10000)
sum = sum + BigDecimal("0.0001")
end

print sum # => 0.1e1
//}

//emlist[例3:...
...cimal("0")
while line = file.gets
s = s + BigDecimal(line)
end

puts s # => 0.3e0
end


File::open("digits.txt", "r") do |file|
s = 0
while line = file.gets
s = s + line.to_f
end

puts s # => 0.30000000000000004
end

//}

2 進数で計算すると誤差が入る可能性があ...
...pi = pi + u
k = k + two
end


u = BigDecimal("1")
k = BigDecimal("1")
w = BigDecimal("1")
t = BigDecimal("956")
while (u.nonzero? && u.exponent >= exp )
t = t.div(m57121,sig)
u = t.div(k,sig)
pi = pi + u
k = k + two
end

pi
end


if $0 == __FILE__
if ARGV...

cgi/session (67.0)

CGI のセッション管理を行うライブラリ。

...'start' if @cmd.empty?
@header = { "type" => "text/html", "charset" => "euc-jp" }

__send__("cmd_#{@cmd}")
end


def cmd_start
@cgi.out(@header) {
<<-END
<html><head><title>CGI::Session Demo</title></head>
<body>
<form action="#{CGI...
...hidden" name="cmd" value="hello">
<input type="submit" value="です。">
</p>
</form>
</body></html>
END

}
end


def cmd_hello
name = Kconv.toeuc(@cgi['name'].first)
@session['name'] = name # セッシ...
...<<-END
<html><head><title>CGI::Session Demo</title></head>
<body>
<p>こんにちは、#{CGI.escapeHTML(name)}さん</p>
<p><a href="#{CGI.escapeHTML(ENV['SCRIPT_NAME'])}?cmd=bye">[次へ]</a></p>
</body></html>
END

}
end


d...

rdoc (61.0)

RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という ドキュメント生成のためのコマンドも含んでいます。

...ントも使え
ますし、=begin/=end でのコメントも使えます。=begin/=end を使う場合は、
以下のように =begin の行に 'rdoc' タグを付ける必要があります。

=begin rdoc
Documentation to
be processed by RDoc.
=end

パラグラフは左のインデン...
...したい場合は all 修飾
子を加えます。

//emlist{
module SM #:nodoc:
class Input
end

end

module Markup #:nodoc: all
class Output
end

end

//}

以上のコードでは、SM::Input のドキュメントのみが出力されます。

: :stopdoc...
...ントに含めます。これは例えば特
定のプライベートメソッドをドキュメントに含めたい場合に便利です。

: :enddoc:

以降の内容を一切ドキュメントに出力しません。

: :notnew:

これはインスタンスメソッドの initialize に...

rexml/parsers/sax2parser (61.0)

SAX2 と同等の API を持つストリーム式の XML パーサ。

...oot>
EOS

class Listener
#include REXML::SAX2Listener
def method_missing(name, *args)
p [name, *args]
end

def respond_to_missing?(name, include_private)
name != :call
end

end


parser = REXML::Parsers::SAX2Parser.new(xml)
parser.listen(Listener.new)
parser.parse
# >> [:start_documen...
..._element, "http://example.org/bar", "b", "bar:b", {}]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/bar", "b", "bar:b"]
# >> [:progress, 683]
# >> [:characters, "\n "]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/default", "a", "a"]
# >> [:progress, 683]
# >> [:char...
...barbarbarbar\n"]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/default", "root", "root"]
# >> [:end_prefix_mapping, nil]
# >> [:end_prefix_mapping, "foo"]
# >> [:end_prefix_mapping, "bar"]
# >> [:progress, 683]
# >> [:characters, "\n"]
# >> [:progress, 683]
# >> [:end_document]
//}...

絞り込み条件を変える

rexml/parsers/streamparser (61.0)

ストリーム式の XML パーサ。

...ener
include REXML::StreamListener
def initialize
@events = []
end


def text(text)
@events << "text[#{text}]"
end


def tag_start(name, attrs)
@events << "tag_start[#{name}]"
end


attr_reader :events
end


xml = <<EOS
<members>
<member name="apple" color="red">
<comme...
...&amp; <!-- comment here--> &bar;
</root>
EOS

class Listener
def method_missing(name, *args)
p [name, *args]
end

def respond_to_missing?(sym, include_private)
true
end

end


REXML::Parsers::StreamParser.new(xml, Listener.new).parse
# >> [:xmldecl, "1.0", "UTF-8", nil]
# >> [:text, "\n...
...]]
# >> [:doctype_end]
# >> [:text, "\n"]
# >> [:tag_start, "root", {"xmlns:foo"=>"http://example.org/foo", "xmlns:bar"=>"http://example.org/bar"}]
# >> [:cdata, "cdata is here"]
# >> [:text, "\n "]
# >> [:tag_start, "a", {"foo:att"=>"1", "bar:att"=>"2", "att"=>"<"}]
# >> [:tag_end, "a"]
# >> [:tex...

cgi (55.0)

CGI プログラムの支援ライブラリです。

...
require 'pstore'
db = PStore.new("query.db")
db.transaction do
db["params"] = cgi.params
end


# 復帰
require 'pstore'
db = PStore.new("query.db")
db.transaction do
cgi.params = db["params"]
end

//}

ただし、PStore は Ruby のバージョンによってデータ互換性が
なくな...
...イアントにクッキーを渡す

//emlist[][ruby]{
require "cgi"
cgi = CGI.new
for name, cookie in cgi.cookies
cookie.expires = Time.now + 30
end

cgi.out("cookie" => cgi.cookies){"string"}

cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }

require "cgi"
cgi = CGI.new
cgi.cookies[...
...it
end
+
cgi.pre() do
CGI.escapeHTML(
"params: " + cgi.params.inspect + "\n" +
"cookies: " + cgi.cookies.inspect + "\n" +
ENV.collect() do |key, value|
key + " --> " + value + "\n"
end
.join("")
)
end

end

end
...

minitest/unit (49.0)

ユニットテストを行うためのライブラリです。

...下のように使います。

テスト対象のソース (foo.rb) を用意します。

class Foo
def foo
"foo"
end

def bar
"foo"
end

end


次にユニットテスト (test_foo.rb) を書きます。
テストを実行するメソッド (テストメソッド) の...
...Case
def setup
@foo = Foo.new
end

# teardown はあまり使わない
def teardown
@foo = nil
end


def test_foo
assert_equal "foo", @foo.foo
end


def test_bar
assert_equal "bar", @foo.bar
end

end


または MiniTest::Unit.autorun を...

test/unit (49.0)

ユニットテストを行うためのライブラリです。

...います。

まずテスト対象のソース(foo.rb)が必要です。

class Foo
def foo
"foo"
end

def bar
"foo"
end

end


次にユニットテスト(test_foo.rb)を書きます。テストを実行するメソッド(テストメソッド)の...
...st::Unit::TestCase
def setup
@obj = Foo.new
end


# def teardown
# end

def test_foo
assert_equal("foo", @obj.foo)
end

def test_bar
assert_equal("bar", @obj.bar)
end

end


テストを実行するには上で用意した test_...
...Base directory of test suites.
-x, --exclude PATTERN Exclude test files on pattern.
-Idirectory Add library load path
--[no-]gc-stress Set GC.stress as true

複数のテストを一度に行う場合、以下のように書いた...

fiddle (43.0)

*.dllや*.soなど、ダイナミックリンクライブラリを扱うためのライブラリです。

...下のようにユーザが定義した
モジュールを拡張する形で使います。

require "fiddle/import"
module M
extend Fiddle::Importer
end


以後、このモジュールで dlload や extern などのメソッドが使用できるようになります。
以下のように...
...を呼んで
ラッパーメソッドを定義します。

require "fiddle/import"
module M
extend Fiddle::Importer
dlload "libc.so.6","libm.so.6"
extern "int strlen(char*)"
end

# Note that we should not include the module M from some reason.

p M.strlen('abc') #=> 3

M.strl...
...M
extend Fiddle::Importer
dlload "libc.so.6"
extern('int gettimeofday(void *, void *)')
Timeval = struct( ["long tv_sec",
"long tv_usec"])
end


timeval = M::Timeval.malloc
e = M.gettimeofday(timeval, nil)

if e == 0
p timeval.tv_sec #=> 1173519547
end


...

絞り込み条件を変える

irb (43.0)

irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。

...irb(main):001:0> 1+2
3
irb(main):002:0> class Foo
irb(main):003:1> def foo
irb(main):004:2> print 1
irb(main):005:2> end
irb(main):006:1> end
:foo
irb(main):007:0>

また irb コマンドは readline ライブラリにも対応しています。
readline ライブラリ...
...-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r と同じ
-I ruby -I と同じ
-U ruby -U と同じ
-E enc ruby -E と同じ
--ve...
...2:0> class Foo;end
nil
irb(main):003:0> irb Foo # Fooをコンテキストしてirb
# 立ちあげ
irb#2(Foo):001:0> def foo # Foo#fooの定義
irb#2(Foo):002:1> print 1
irb#2(Foo):003:1> end
nil
irb#2...
<< < 1 2 3 4 ... > >>