るりまサーチ

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

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. integer >
  5. module >

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

String#tr(pattern, replace) -> String (21350.0)

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

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

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

//emlist[例][ruby]{
p "foo".tr("f", "X") # => "Xoo"
p "foo".tr('a-z', 'A-Z') # => "FOO"
p "FOO".tr('A-Z', 'a-z') # => "foo"

# シーザー暗号の復号
p "ORYV".tr("A-Z", "D-ZA-C") # => "RUBY"

# 全角英数字といくつかの記号の半角化
ema...
...il = "ruby−lang@example.com"
p email.tr("0-9a-zA-Z.@−", "0-9a-zA-Z.@-")
# => "ruby-lang@example.com"
//}

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

Matrix#tr -> Integer | Float | Rational | Complex (21202.0)

トレース (trace) を返します。

...トレース (trace) を返します。

行列のトレース (trace) とは、対角要素の和です。

//emlist[例][ruby]{
require 'matrix'
Matrix[[7,6], [3,9]].trace # => 16
//}

tr
ace は正方行列でのみ定義されます。

@raise ExceptionForMatrix::ErrDimensionMismatch 行列が...

String#tr_s(pattern, replace) -> String (9368.0)

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

...えます。さらに、
置換した部分内に同一の文字の並びがあったらそれを 1 文字に圧縮します。

pattern の形式は tr(1) と同じです。
つまり「a-c」は a から c を意味し、
"^0-9" のように文字列の先頭が「^」の場合は指定した文...
...ooooogle".tr_s("o", "X") # => "gXgle"
p "gooooogle".tr_s("a-z", "A-Z") # => "GOGLE"
//}

注意:
一般に、tr_s を tr と squeeze で置き換えることはできません。
tr
と squeeze の組みあわせでは tr の置換後の文字列全体を squeeze しますが、
tr
_s は置...
...換された部分だけを squeeze します。
以下のコードを参照してください。

//emlist[例][ruby]{
p "foo".tr_s("o", "f") # => "ff"
p "foo".tr("o", "f").squeeze("f") # => "f"
//}

@see String#tr...

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

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

...属性は REXML::Attribute オブジェクトで渡されます。

//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_elemen...
...ts("/root/a").first

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", "<"]
//}...

REXML::Attributes#get_attribute(name) -> Attribute | nil (9307.0)

name という名前の属性を取得します。

...ML::Attributes#[]

//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").first

a.attributes.get_attribute...
...("att") # => att='&lt;'
a.attributes.get_attribute("foo:att") # => foo:att='1'
//}...

絞り込み条件を変える

REXML::Attributes#get_attribute_ns(namespace, name) -> REXML::Attribute | nil (9307.0)

namespace と name で特定される属性を返します。

...">
<a foo:att='1' bar:att='2' att='&lt;'/>
</root>
EOS
a = doc.get_elements("/root/a").first

a.attributes.get_attribute_ns("", "att") # => att='&lt;'
a.attributes.get_attribute_ns("http://example.org/foo", "att") # => foo:att='1'
a.attributes.get_attribute_ns("http://example.org/baz", "att") # =>...
...nil
a.attributes.get_attribute_ns("http://example.org/foo", "attt") # => nil
//}...

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

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

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

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

@r...

Matrix#entrywise_product(m) -> Matrix (9301.0)

アダマール積(要素ごとの積)を返します。

...ダマール積(要素ごとの積)を返します。

@raise ExceptionForMatrix::ErrDimensionMismatch 行や列の要素数が一致しない時に発生します。

//emlist[例][ruby]{
require 'matrix'

Matrix[[1,2], [3,4]].hadamard_product(Matrix[[1,2], [3,2]]) # => Matrix[[1, 4], [9, 8]]
//}...

Matrix::EigenvalueDecomposition#eigenvector_matrix -> Matrix (9301.0)

右固有ベクトルを横に並べた行列を返します。

右固有ベクトルを横に並べた行列を返します。

Matrix::EigenvalueDecomposition#eigenvector_matrix_inv -> Matrix (9301.0)

左固有ベクトルを縦に並べた行列を返します。

...左固有ベクトルを縦に並べた行列を返します。

これは Matrix::EigenvalueDecomposition#v の逆行列です...

絞り込み条件を変える

<< 1 2 3 ... > >>