るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

test/unit (26018.0)

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

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

* Test::Unit - Ruby用単体テストフレームワーク: https://test-unit.github.io/

なお、2.2.0より前のtest/unit は当時バンドルしていた minitest/unit を使って再実装し
ていましたが、上記のtest/unitと完全な互換性がある...
...ィングフレームワークの歴史(2014年版) https://www.clear-code.com/blog/2014/11/6.html
* RubyKaigi 2015:The history of testing framework in Ruby https://www.clear-code.com/blog/2015/12/12.html

=== 使い方

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

まずテスト対象...
...ら単体テストの高速化のために、並列実行がサポートされました。

並列化の仕組みについては以下の記事をご覧ください。

* Rubyist Magazine 0033 号 詳解! test-all 並列化: https://magazine.rubyist.net/articles/0033/0033-ParallelizeTestAll.html...

BasicObject#! -> bool (21125.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...@return オブジェクトが偽であれば真、さもなくば偽

//emlist[例][ruby]{
class NegationRecorder < BasicObject
def initialize
@count = 0
end
attr_reader :count

def !
@count += 1
super
end
end

recorder = NegationRecorder.new
!
recorder
!
!!!!!!recorder
puts 'h...
...oge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
def !
t
rue
end
end
another_false = AnotherFalse.new

# another_falseは*真*
puts "another false is a truth" if another_false
#=> "another false is a truth"
//}...

Delegator#! -> bool (21101.0)

自身を否定します。

自身を否定します。

String#tr_s!(pattern, replace) -> self | nil (15260.0)

文字列の中に pattern 文字列に含まれる文字が存在したら、 replace 文字列の対応する文字に置き換えます。さらに、 置換した部分内に同一の文字の並びがあったらそれを 1 文字に圧縮します。

...文字列の中に pattern 文字列に含まれる文字が存在したら、
replace 文字列の対応する文字に置き換えます。さらに、
置換した部分内に同一の文字の並びがあったらそれを 1 文字に圧縮します。

pattern の形式は tr(1) と同じです...
...は指定した文字以外が置換の対象になります。

replace でも「-」を使って範囲を指定できます。

//emlist[][ruby]{
p "gooooogle".tr_s("a-z", "A-Z") # => "GOGLE"
//}

「-」は文字列の両端にない場合にだけ範囲指定の意味になります。
同様...
...す。

t
r_s は置換後の文字列を生成して返します。
t
r_s! は self を変更して返しますが、
置換が起こらなかった場合は nil を返します。

注意:
一般に、tr_s! tr! と squeeze! で置き換えることはできません。
t
r! と squeeze! の組み...

String#strip! -> self | nil (15241.0)

先頭と末尾の空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

..." \t\r\n\f\v\0" です。

strip! は、内容を変更した self を返します。
ただし取り除く空白がなかったときは nil を返します。

//emlist[例][ruby]{
str = " abc\r\n"
p str.strip! #=> "abc"
p str #=> "abc"

str = "abc"
p str.strip! #=> nil
p str...
...#=> "abc"

str = " \0 abc \0"
str.strip!
p str #=> "abc"
//}

@see String#strip, String#lstrip...

絞り込み条件を変える

String#lstrip! -> self | nil (15235.0)

文字列の先頭にある空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

...義は " \t\r\n\f\v\0" です。

lstrip! は self を変更して返します。
ただし取り除く空白がなかったときは nil を返します。

//emlist[例][ruby]{
str = " abc"
p str.lstrip! # => "abc"
p str # => "abc"

str = "abc"
p str.lstrip! # => nil
p str...

String#rstrip! -> self | nil (15235.0)

文字列の末尾にある空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

...的に取り除きます。
空白文字の定義は " \t\r\n\f\v\0" です。

//emlist[例][ruby]{
str = " abc\n"
p str.rstrip! # => " abc"
p str # => " abc"

str = " abc \r\n\t\v\0"
p str.rstrip! # => " abc"
p str # => " abc"
//}

@see String#rstrip, String#lstrip...

String#tr!(pattern, replace) -> self | nil (15206.0)

pattern 文字列に含まれる文字を検索し、 それを replace 文字列の対応する文字に破壊的に置き換えます。

...pattern 文字列に含まれる文字を検索し、
それを replace 文字列の対応する文字に破壊的に置き換えます。

pattern の形式は tr(1) と同じです。
つまり、`a-c' は a から c を意味し、
"^0-9" のように文字列の先頭が `^' の場合は
指定...
...

replace の範囲が pattern の範囲よりも小さい場合は、
replace の最後の文字が無限に続くものと扱われます。

t
r! は self を変更して返しますが、
置換が起こらなかった場合は nil を返します。

@param pattern 置き換える文字の...
...パターン
@param replace pattern で指定した文字を置き換える文字

@see String#tr, String#tr_s...

Array#filter! {|item| block } -> self | nil (12316.0)

ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。 変更があった場合は self を、 変更がなかった場合には nil を返します。

...//emlist[例][ruby]{
a = %w{ a b c d e f }
a.select! {|v| v =~ /[a-z]/ } # => nil
a # => ["a", "b", "c", "d", "e", "f"]
//}

ブロックが与えられなかった場合は、自身と select! から生成した
Enumerator オブジェクトを返します。

@see Array#keep_if, Array#reject!...

Hash#filter! -> Enumerator (12234.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...ます。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{...
...h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h1.select! { |k, v| true } # => nil
h2.keep_if { |k, v|...
...k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h2.keep_if { |k, v| true } # => {0=>"a", 3=>"d", 6=>"g"}
//}

@see Hash#select, Hash#delete_if, Hash#reject!...

絞り込み条件を変える

Hash#filter! {|key, value| ... } -> self | nil (12234.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...ます。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{...
...h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h1.select! { |k, v| true } # => nil
h2.keep_if { |k, v|...
...k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h2.keep_if { |k, v| true } # => {0=>"a", 3=>"d", 6=>"g"}
//}

@see Hash#select, Hash#delete_if, Hash#reject!...
<< 1 2 3 ... > >>