るりまサーチ

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

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. argf.class readlines
  5. argf.class set_encoding

検索結果

<< < 1 2 >>

e2mmap (31.0)

例外クラスに特定のエラーメッセージ用フォーマットを関連づけるためのライブラリです。

...eMapper を extend すれば、
def_e2message メソッドや def_exception メソッドが使えます。
これらで例外クラスとメッセージを関連づけることができます。

例:

class
Foo
extend
Exception2MessageMapper
def_e2message ExistingExceptionClass, "message....
...f_exception :NewExceptionClass, "message...", StandardError
...
end

foo = Foo.new
foo.Fail ....

2. 何度も使いたい例外クラスは、クラスの代わりにモジュールで定義して、
それを include して使います。

例:

module ErrorMod
extend
Exception2M...
...essageMapper
def_e2message ExistingExceptionClass, "message..."
def_exception :NewExceptionClass, "message...", StandardError
...
end
class
Foo
include ErrorMod
...
end

foo = Foo.new
foo.Fail ....

3. 例外を設定したクラスのインスタンス以外から例...

rdoc/parser/c (31.0)

C 言語で記述されたソースコードから組み込みクラス/モジュールのドキュメン トを解析するためのサブライブラリです。

...使用します。
rb_define_class や rb_define_method などで定義されたものに
対応する C 言語の関数のコメントを解析します。

例: Array#flatten の場合。rb_ary_flatten のコメントが解析されます。

/*
* Returns a new array that is a one-dimensional...
...flattening of this
* array (recursively). That is, for every element that is an array,
* extract its elements into the new array.
*
* s = [ 1, 2, 3 ] #=> [1, 2, 3]
* t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
* a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4,...
...あります。

また、Ruby のソースコードとは別にコメントには特別な命令を指定する事がで
きます。

: Document-class: name

記述する内容を name で指定した Ruby のクラスのものに指定します。同じ
.c ファイルに複数のクラス定...

rexml/parsers/sax2parser (25.0)

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

...よりは高機能です。

//emlist[][ruby]{
require 'rexml/parsers/sax2parser'
require 'rexml/sax2listener'

parser = REXML::Parsers::SAX2Parser.new(<<XML)
<root n="0">
<a n="1">111</a>
<b n="2">222</b>
<a n="3">333</a>
</root>
XML

elements = []
parser.listen(:start_element){|uri, localnam...
...e--> &bar;
</root>
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
# >> [...

tsort (25.0)

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

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

=== Example

//emlist[][ruby]{
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=...
...== より現実的な例

非常に単純な `make' に似たツールは以下のように実装できます。

//emlist[][ruby]{
require 'tsort'

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

def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]...
...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 =...

irb (19.0)

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

...は 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>

また i...
...-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...
...PT_S => "%N(%m):%03n:%i%l ",
:PROMPT_C => "%N(%m):%03n:%i* ",
:RETURN => "%s\n"
}

プロンプトモードは :DEFAULT
の他に :NULL, :CLASSIC, :SIMPLE, :XMP が定義されています。

=== サブ irb

irb では、起動時の irb インタプリタとは独立した環境を持つ...

絞り込み条件を変える

minitest/unit (19.0)

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

...ブラリです。

=== 使い方

minitest/unit は以下のように使います。

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

class
Foo
def foo
"foo"
end
def bar
"foo"
end
end

次にユニットテスト (test_foo.rb) を書きます。
テスト...
...ストが自動実行されません。

require 'minitest/unit'
require 'foo'

MiniTest::Unit.autorun

class
TestFoo < MiniTest::Unit::TestCase
def setup
@foo = Foo.new
end
# teardown はあまり使わない
def teardown
@foo = nil
end

def test_fo...

test/unit (19.0)

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

...blog/2015/12/12.html

=== 使い方

Test::Unit は以下のように使います。

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

class
Foo
def foo
"foo"
end
def bar
"foo"
end
end

次にユニットテスト(test_foo.rb)を書...
...たあとには、teardown メソッドが必ず呼ばれます。

require 'test/unit'
require 'foo'

class
TC_Foo < Test::Unit::TestCase
def setup
@obj = Foo.new
end

# def teardown
# end

def test_foo
assert_equal("foo", @obj.foo)
en...
...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

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

coverage (13.0)

カバレッジを測定するためのライブラリです。

...モードでは、各メソッドの実行回数を計測します。

//emlist[foo_method.rb][ruby]{
class
Greeter
def greet
"welcome!"
end
end

def hello
"Hi"
end

hello()
Greeter.new.greet()
//}

//emlist[][ruby]{
require "coverage"
Coverage.start(methods: true)
load "foo_method.rb"
pp...

irb/completion (13.0)

irb の completion 機能を提供するライブラリです。

...d instance_of?
initialize install_aliases instance_variables
irb(main):001:0> inspect
"main"
irb(main):002:0> foo = Object.new
#<Object:0x4027146c>

"変数名." の後に [Tab] を押すと, そのオブジェクトのメソッド一覧がでます.

irb(main):003:0> f...
...espond_to?
foo.__id__ foo.inspect foo.send
foo.__send__ foo.instance_eval foo.singleton_methods
foo.class foo.instance_of? foo.taint
foo.clone foo.instance_variables foo.tainted?
foo.display foo.is_a?...
...foo.to_a
foo.dup foo.kind_of? foo.to_s
foo.eql? foo.method foo.type
foo.equal? foo.methods foo.untaint
foo.extend foo.nil?
foo.freeze foo.private_methods...

rdoc/generator/json_index (13.0)

他のジェネレータが生成する HTML で検索が行えるように、JSON の検索インデッ クスを生成するサブライブラリです。

...レータと一緒に使うために設計されています。:

class
RDoc::Generator::Darkfish
def initialize options
# ...
@base_dir = Pathname.pwd.expand_path

@json_index = RDoc::Generator::JsonIndex.new self, options
end

def generate
# ...
@json_in...

絞り込み条件を変える

<< < 1 2 >>