るりまサーチ (Ruby 3.2)

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

別のキーワード

  1. _builtin at
  2. _builtin values_at
  3. time at
  4. dbm values_at
  5. gdbm values_at

検索結果

REXML::Attribute#element -> REXML::Element (72910.0)

その属性が属する要素を返します。

その属性が属する要素を返します。

REXML::Element#each_element_with_attribute(key, value = nil, max = 0, name = nil) {|element| ... } -> () (64282.0)

特定の属性を持つすべての子要素を引数としてブロックを呼び出します。

特定の属性を持つすべての子要素を引数としてブロックを呼び出します。

key で指定した属性名の属性を持つ要素のみを対象とします。
value を指定すると、keyで指定した属性名を持つ属性の値がvalueである
もののみを対象とします。
maxを指定すると、対象となる子要素の先頭 max 個のみが対象となります。
name を指定すると、それは xpath 文字列と見なされ、
それにマッチするもののみが対象となります。

max に 0 を指定すると、max の指定は無視されます(0個ではありません)。

@param key 属性名(文字列)
@param value 属性値(文字列)
...

Matrix#element(i, j) -> () (63307.0)

(i,j)要素を返します。 行列の範囲外の値を指定した場合には nil を返します。

(i,j)要素を返します。
行列の範囲外の値を指定した場合には nil を返します。

@param i 要素の行成分を0オリジンで指定します。
@param j 要素の列成分を0オリジンで指定します。



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

a1 = [1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, 2, 1.5]
m = Matrix[a1, a2, a3]

p m[0, 0] # => 1
p m[1, 1] # => 15
p m[1, 2] # => 20
p m[1, 3] # => nil
//}

REXML::Element#delete_attribute(key) -> REXML::Attribute | nil (46222.0)

要素から key という属性名の属性を削除します。

要素から key という属性名の属性を削除します。

削除された属性を返します。

key という属性名の属性が存在しない場合は削除されずに、nil を返します。

@param key 削除する要素(文字列(属性名) or REXML::Attributeオブジェクト)

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("E")
e.add_attribute("x", "foo"); e # => <E x='foo'/>
e.add_attribute("y:x", "bar"); e # => <E x...

REXML::Element#attribute(name, namespace = nil) -> REXML::Attribute | nil (46204.0)

name で指定される属性を返します。

name で指定される属性を返します。

属性は REXML::Attribute オブジェクトの形で返します。

name は "foo:bar" のように prefix を指定することができます。

namespace で名前空間の URI を指定することで、その名前空間内で
name という属性名を持つ属性を指定できます。

指定した属性名の属性がない場合は nil を返します。

@param name 属性名(文字列)
@param namespace 名前空間のURI(文字列)
//emlist[][ruby]{
require 'rexml/document'

doc = R...

絞り込み条件を変える

REXML::Element#attributes -> REXML::Attributes (46204.0)

要素が保持している属性の集合を返します。

要素が保持している属性の集合を返します。

REXML::Element#add_attributes(attrs) -> () (45940.0)

要素の属性を複数追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。

要素の属性を複数追加します。
同じ名前の属性がすでにある場合はその属性を新しい
属性で置き換えます。

attrs には Hash もしくは Array を指定できます。
Hash の場合は、
{ "name1" => "value1", "name2" => "value2", ... }
という形で、配列の場合は
[ ["name1", "value1"], ["name2", "value2"], ... }
という形で追加/更新する属性を指定します。

@param attrs 追加する属性の属性名と属性値の対の集合(Array or Hash)

//emlist[][rub...

Matrix#elements_to_r -> Matrix (45925.0)

各要素を有理数 Rational に変換した行列を返します。

各要素を有理数 Rational に変換した行列を返します。

このメソッドは deprecated です。 map(&:to_r) を使ってください。

REXML::Element#add_attribute(attr) -> () (45904.0)

要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。

要素の属性を追加します。
同じ名前の属性がすでにある場合はその属性を新しい
属性で置き換えます。

引数の与えかたは2通りあります。
要素名と値の2つの文字列で渡す方法と REXML::Attribute オブジェクトを
渡す方法です。

文字列2つで指定する場合、属性値は unnormalized な文字列を渡す必要があります。

@param key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブジェクト)

//emlist[][ruby]{
require 'rexml/document'
doc = ...

REXML::Element#add_attribute(key, value) -> () (45604.0)

要素の属性を追加します。 同じ名前の属性がすでにある場合はその属性を新しい 属性で置き換えます。

要素の属性を追加します。
同じ名前の属性がすでにある場合はその属性を新しい
属性で置き換えます。

引数の与えかたは2通りあります。
要素名と値の2つの文字列で渡す方法と REXML::Attribute オブジェクトを
渡す方法です。

文字列2つで指定する場合、属性値は unnormalized な文字列を渡す必要があります。

@param key 属性名(文字列)
@param value 属性値(文字列)
@param attr 属性(REXML::Attribute オブジェクト)

//emlist[][ruby]{
require 'rexml/document'
doc = ...

絞り込み条件を変える

REXML::Element#has_attributes? -> bool (45604.0)

要素が属性を1つ以上持っていれば真を返します。

要素が属性を1つ以上持っていれば真を返します。

REXML::DocType#attribute_of(element, attribute) -> String | nil (37945.0)

DTD 内の属性リスト宣言で、 element という名前の要素の attribute という 名前の属性のデフォルト値を返します。

DTD 内の属性リスト宣言で、 element という名前の要素の attribute という
名前の属性のデフォルト値を返します。

elementという名前の要素の属性値は宣言されていない、
elementという名前の要素にはattributeという名前の属性が宣言されていない、
もしくはデフォルト値が宣言されていない、のいずれかの場合は nil を返します。

@param element 要素名(文字列)
@param attribute 属性名(文字列)

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

doctype = REXML::Doc...

REXML::Element#add_element(element, attrs = nil) -> Element (37693.0)

子要素を追加します。

子要素を追加します。

element として追加する要素を指定します。
REXML::Element オブジェクトもしくは文字列を指定します。

element として REXML::Element オブジェクトを指定した場合、それが追加されます。
文字列を指定した場合は、それを要素名とする要素を追加します。

attrs に { String => String } という Hash を渡すと、
追加する要素の属性を指定できます。

子要素の最後に追加されます。

返り値は追加された要素です。

@param element 追加する要素
@param attrs 追加する要素に設定する...

REXML::DocType#attributes_of(element) -> [REXML::Attribute] (37591.0)

DTD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている 属性の名前とデフォルト値を REXML::Attribute の配列で返します。

DTD 内の属性リスト宣言で、 element という名前の要素に対し宣言されている
属性の名前とデフォルト値を REXML::Attribute の配列で返します。

名前とデフォルト値のペアは、各 Attribute オブジェクトの
REXML::Attribute#name と
REXML::Attribute#value で表現されます。

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

doctype = REXML::Document.new(<<EOS).doctype
<!DOCTYPE books [
<!ELEMENT book (c...

REXML::StreamListener#attlistdecl(element_name, attributes, raw_content) -> () (37243.0)

DTDの属性リスト宣言をパースしたときに呼び出されるコールバックです。

DTDの属性リスト宣言をパースしたときに呼び出されるコールバックです。

@param element_name 要素名が文字列で渡されます
@param attributes 属性名とそのデフォルト値の対応が
{ 属性名文字列 => デフォルト値文字列(無ければnil) } という
ハッシュテーブルで渡されます
@param raw_content 文書内の属性リスト宣言の文字列がそのまま渡されます

=== 例
<!ATTLIST a att CDATA #REQUIRED xyz CDATA "foobar">
という属性リスト宣言に対しては
element_...

絞り込み条件を変える

REXML::Element#get_elements(xpath) -> [REXML::Element] (37207.0)

xpath にマッチする要素を配列で返します。

xpath にマッチする要素を配列で返します。

xpath には XPath 文字列を指定します。

@param xpath XPath 文字列
@see REXML::Elements#to_a

REXML::Element#each_element(xpath = nil) {|element| ... } -> () (36910.0)

各子要素を引数としてブロックを呼び出します。

各子要素を引数としてブロックを呼び出します。

xpath に文字列を指定するとそれにマッチする子要素のみを対象とします。

@param xpath XPath 文字列

REXML::SAX2Listener#start_element(uri, localname, qname, attributes) -> () (36907.0)

要素が開始されたときに呼び出されるコールバックメソッドです。

要素が開始されたときに呼び出されるコールバックメソッドです。

@param uri 名前空間のURI文字列が渡されます。対応する名前空間が存在しない場合は
nil が渡されます
@param localname 接頭辞を取り除いた要素名文字列が渡されます
@param qname 修飾名(qualified-name)文字列、つまり接頭辞を含む文字列が渡されます
@param attribute 属性が { 属性名 => 属性値文字列 } という Hash で
で渡されます。

Matrix#elements_to_f -> Matrix (36904.0)

各要素を浮動小数点数 Float に変換した行列を返します。

各要素を浮動小数点数 Float に変換した行列を返します。

このメソッドは deprecated です。 map(&:to_f) を使ってください。

Matrix#elements_to_i -> Matrix (36904.0)

各要素を整数 Integer に変換した行列を返します。

各要素を整数 Integer に変換した行列を返します。

このメソッドは deprecated です。 map(&:to_i) を使ってください。

絞り込み条件を変える

REXML::Element#cdatas -> [REXML::CData] (36904.0)

すべての cdata 子ノードの配列を返します。

すべての cdata 子ノードの配列を返します。

返される配列は freeze されます。

REXML::Attribute#element=(element) (36646.0)

self が属する要素を変更します。

self が属する要素を変更します。

@param element 変更先の要素(REXML::Element)

REXML::AttlistDecl#element_name -> String (36607.0)

属性を定義しているエレメントの名前を返します。

属性を定義しているエレメントの名前を返します。

REXML::Element#xpath -> String (36604.0)

文書上の対象の要素にのみマッチする xpath 文字列を返します。

文書上の対象の要素にのみマッチする xpath 文字列を返します。

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><b/><c/></a>')
c = doc.root.elements[2] # <a> .. </a> の中の <c/> 要素
c # => <c/>
c.xpath # => "/a/c"
doc = REXML::Document.new('<a><b/><b/></a>')
b = doc.root.elements[2] # <a> .. </a> の中の2番目の <b...

REXML::Attribute#prefix -> String (36322.0)

属性の名前空間を返します。

属性の名前空間を返します。

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new( "elns:myelement" )
e.add_attribute( "nsa:a", "aval" )
e.add_attribute( "b", "bval" )
p e.attributes.get_attribute( "a" ).prefix # -> "nsa"
p e.attributes.get_attribute( "b" ).prefix # -> "elns"
a = REXML::Attribute...

絞り込み条件を変える

REXML::SAX2Listener#attlistdecl(element, pairs, contents) -> () (27925.0)

DTDの属性リスト宣言に対し呼び出されるコールバックメソッドです。

DTDの属性リスト宣言に対し呼び出されるコールバックメソッドです。

@param element 要素名が文字列で渡されます
@param pairs 属性名とそのデフォルト値の対応が
{ 属性名文字列 => デフォルト値文字列(無ければnil) } という
ハッシュテーブルで渡されます
@param contents 文書内の属性リスト宣言の文字列がそのまま渡されます

REXML::Attribute#to_string -> String (27676.0)

"name='value'" という形式の文字列を返します。

"name='value'" という形式の文字列を返します。

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("ns:r", "rval")
p e.attributes.get_attribute("r").to_string # => "ns:r='rval'"
//}

Matrix#combine(*matrices) {|*elements| ... } -> Matrix (19504.0)

要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。

要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。

Matrix.combine(self, *matrices) { ... } と同じです。

@see Matrix.combine

REXML::Elements#each(xpath = nil) {|element| ... } -> [REXML::Elements] (19207.0)

全ての子要素に対しブロックを呼び出します。

全ての子要素に対しブロックを呼び出します。

xpath を指定した場合には、その XPath 文字列に
マッチする要素に対しブロックを呼び出します。

REXML::XPath.each などとは異なり、要素以外の
テキストノードなどはすべて無視されることに注意してください。

@param xpath XPath文字列

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
# <b/>,...

REXML::Attributes#delete(attribute) -> REXML::Element (18925.0)

指定した属性を取り除きます。

指定した属性を取り除きます。

attribute で取り除く属性を指定します。
文字列もしくは REXML::Attribute オブジェクトを指定します

self が属する要素(REXML::Element)を返します。

@param attribute 取り除く属性(文字列もしくは REXML::Attribute オブジェクト)

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

doc = REXML::Document.new(<<-EOS)
<root xmlns:foo="http://example.org/foo"
x...

絞り込み条件を変える

REXML::Elements#delete_all(xpath) -> [REXML::Element] (18907.0)

xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

xpath で指定した XPath 文字列にマッチする要素をすべて取り除きます。

@param xpath 取り除く要素を指し示す XPath 文字列

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new('<a><c/><c/><c/><c/></a>')
doc.elements.delete_all("a/c") # => [<c/>, <c/>, <c/>, <c/>]
doc.to_s # => "<a/>"
//}

REXML::Elements#to_a(xpath = nil) -> [REXML::Element] (18907.0)

すべての子要素の配列を返します。

すべての子要素の配列を返します。

xpath を指定した場合は、その XPath 文字列に
マッチする要素の配列を返します。

REXML::Elements#each と同様、REXML::XPath.match などと
異なり、要素以外の子ノードは無視されます。

@param xpath XPath文字列

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_...

Matrix#collect!(which = :all) -> Enumerator (18646.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

@param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each の項目を参照して下さい。


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

Matrix#map!(which = :all) -> Enumerator (18646.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

@param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each の項目を参照して下さい。


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

REXML::Element#get_text(path = nil) -> REXML::Text | nil (18622.0)

先頭のテキスト子ノードを返します。

先頭のテキスト子ノードを返します。

raw モードの設定は無視され、常に正規化されたテキストを返します。
REXML::Text#value も参照してください。

path を渡した場合は、その XPath 文字列で指定される
テキストノードの文字列を返します。

テキストノードがない場合には nil を返します。

@param path XPath文字列
@see REXML::Element#text

//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new "<p>some text <b>this ...

絞り込み条件を変える

REXML::Element#text(path = nil) -> String | nil (18622.0)

先頭のテキスト子ノードの文字列を返します。

先頭のテキスト子ノードの文字列を返します。

テキストノードを複数保持している場合は最初のノードにしか
アクセスできないことに注意してください。

raw モードの設定は無視され、常に正規化されたテキストを返します。
REXML::Text#value も参照してください。

path を渡した場合は、その XPath 文字列で指定される
テキストノードの文字列を返します。

テキストノードがない場合には nil を返します。

@param path XPath文字列
@see REXML::Element#get_text

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

Array#drop_while -> Enumerator (18607.0)

ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。 このメソッドは自身を破壊的に変更しません。

ブロックを評価して最初に偽となった要素の手前の要素まで捨て、
残りの要素を配列として返します。
このメソッドは自身を破壊的に変更しません。

ブロックを指定しなかった場合は、Enumerator を返します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]

# 変数aの値は変化しない
a # => [1, 2, 3, 4, 5, 0]
//}

@see Enumerable#drop_while, Array...

Enumerable#drop_while -> Enumerator (18607.0)

ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。

ブロックを評価して最初に偽となった要素の手前の要素まで捨て、
残りの要素を配列として返します。

ブロックを指定しなかった場合は、Enumerator を返します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
//}

Enumerable#reverse_each -> Enumerator (18607.0)

逆順に各要素に対してブロックを評価します。

逆順に各要素に対してブロックを評価します。

内部で各要素を保持した配列を作ります。

ブロックを省略した場合は、各要素を逆順に辿る
Enumerator を返します。

//emlist[例][ruby]{
{a: 1, b: 2, c: 3}.reverse_each # => #<Enumerator: ...>
{a: 1, b: 2, c: 3}.reverse_each { |v| p v }
# => [:c, 3]
# [:b, 2]
# [:a, 1]
//}

REXML::Attribute#clone -> REXML::Element (18607.0)

self を複製し返します。

self を複製し返します。

絞り込み条件を変える

REXML::Elements#collect(xpath = nil) {|element| .. } -> [object] (18607.0)

Enumerable#collect と同様、 各子要素に対しブロックを呼び出し、その返り値の配列を返します。

Enumerable#collect と同様、
各子要素に対しブロックを呼び出し、その返り値の配列を返します。

xpath を指定した場合は、その XPath 文字列に
マッチする要素に対し同様の操作をします。

@param xpath XPath文字列
@see REXML::Elements#each

REXML::Elements#inject(xpath = nil, initial = nil) {|element| ... } -> object (18607.0)

Enumerable#inject と同様、 各子要素に対し畳み込みをします。

Enumerable#inject と同様、
各子要素に対し畳み込みをします。

xpath を指定した場合は、その XPath 文字列に
マッチする要素に対し同様の操作をします。

@param xpath XPath文字列
@see REXML::Elements#each

Module#ruby2_keywords(method_name, ...) -> nil (18418.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

For the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword argument...

Proc#ruby2_keywords -> proc (18418.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked ...

REXML::Attribute#namespace(arg = nil) -> String | nil (18376.0)

属性の名前空間の URI を返します。

属性の名前空間の URI を返します。

URI が定義されていない場合は nil を返します。

@param arg この値を指定すると、その属性の名前空間でなく、arg という名前空間
の URI が返されます。
通常は省略します。

//emlist[][ruby]{
require 'rexml/document'
e = REXML::Element.new("el")
e.add_attribute("xmlns:ns", "http://www.example.com/ns")
e.add_attribute("ns:r", "rval")
p e....

絞り込み条件を変える

Matrix#collect!(which = :all) {|element| ... } -> self (18346.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

@param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each の項目を参照して下さい。


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

Matrix#map!(which = :all) {|element| ... } -> self (18346.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

@param which which に以下の Symbol を指定することで、
引数として使われる要素を限定できます。
デフォルトは、:all (全ての要素)です。
指定できる Symbol の詳細は、 Matrix#each の項目を参照して下さい。


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

Matrix#[](i, j) -> () (18007.0)

(i,j)要素を返します。 行列の範囲外の値を指定した場合には nil を返します。

(i,j)要素を返します。
行列の範囲外の値を指定した場合には nil を返します。

@param i 要素の行成分を0オリジンで指定します。
@param j 要素の列成分を0オリジンで指定します。



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

a1 = [1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, 2, 1.5]
m = Matrix[a1, a2, a3]

p m[0, 0] # => 1
p m[1, 1] # => 15
p m[1, 2] # => 20
p m[1, 3] # => nil
//}

Matrix#component(i, j) -> () (18007.0)

(i,j)要素を返します。 行列の範囲外の値を指定した場合には nil を返します。

(i,j)要素を返します。
行列の範囲外の値を指定した場合には nil を返します。

@param i 要素の行成分を0オリジンで指定します。
@param j 要素の列成分を0オリジンで指定します。



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

a1 = [1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, 2, 1.5]
m = Matrix[a1, a2, a3]

p m[0, 0] # => 1
p m[1, 1] # => 15
p m[1, 2] # => 20
p m[1, 3] # => nil
//}

Vector#collect! -> Enumerator (9610.0)

ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。

ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

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

v = Vector[1, 2, 3]
p v.map!{ |el| el * 2 } #=> Vector[2, 4, 6]
p v #=> Vector[2, 4, 6]
//}

絞り込み条件を変える

Vector#map! -> Enumerator (9610.0)

ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。

ベクトルの各要素を順番にブロックに渡して評価し、その結果で要素を置き換えます。

ブロックのない場合は、自身と map! から生成した Enumerator オブジェクトを返します。

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

v = Vector[1, 2, 3]
p v.map!{ |el| el * 2 } #=> Vector[2, 4, 6]
p v #=> Vector[2, 4, 6]
//}

Array#take_while -> Enumerator (9607.0)

配列の要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。 このメソッドは自身を破壊的に変更しません。

配列の要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。
このメソッドは自身を破壊的に変更しません。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.take_while {|i| i < 3 } # => [1, 2]
//}

ブロックを省略した場合は Enumerator を返します。

@see Enumerable#take_while

Enumerable#take_while -> Enumerator (9607.0)

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。

Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。

//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}

ブロックを省略した場合は Enumerator を返します。

@see Array#take_while