るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 > >>

Data#hash -> Integer (26133.0)

自身のハッシュ値を整数で返します。 Data#eql? で比較して等しいオブジェクトは同じハッシュ値を返します。

...を返します。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5)
p dog1.hash # => -3931425561194935428
dog2 = Dog.new("Fred", 5)
p dog2.hash # => -3931425561194935428
dog3 = Dog.new("Fred", 6)
p dog3.hash # => -4469132459285820530
//}

[注意] 本メソッドの記...
...述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。

@see Object#hash...

Struct#hash -> Integer (26127.0)

self が保持するメンバのハッシュ値を元にして算出した整数を返します。 self が保持するメンバの値が変化すればこのメソッドが返す値も変化します。

...ばこのメソッドが返す値も変化します。

//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog = Dog.new("fred", 5)
p dog.hash #=> 7917421
dog.name = "john"
p dog.hash #=> -38913223
//}

[注意] 本メソッドの記述は Struct の下位クラ...

MatchData#named_captures -> Hash (14231.0)

名前付きキャプチャをHashで返します。

...キャプチャをHashで返します。

Hash
のキーは名前付きキャプチャの名前です。Hashの値はキーの名前に対応した名前付きグループのうち最後にマッチした文字列です。

//emlist[例][ruby]{
m = /(?<a>.)(?<b>.)/.match("01")
m.named_captures # => {...
..."a" => "0", "b" => "1"}

m = /(?<a>.)(?<b>.)?/.match("0")
m.named_captures # => {"a" => "0", "b" => nil}

m = /(?<a>.)(?<a>.)/.match("01")
m.named_captures # => {"a" => "1"}

m = /(?<a>x)|(?<a>y)/.match("x")
m.named_captures # => {"a" => "x"}
//}

@see MatchData#captures...

Regexp#named_captures -> { String => [Integer] } (14130.0)

正規表現に含まれる名前付きキャプチャ(named capture)の情報を Hash で返します。

...付きキャプチャ(named capture)の情報を
Hash
で返します。

Hash
のキーは名前付きキャプチャの名前で、値は
その名前に関連付けられたキャプチャの index のリストを返します。

//emlist[例][ruby]{
/(?<foo>.)(?<bar>.)/.named_captures
# => {"foo...
..."=>[1], "bar"=>[2]}

/(?<foo>.)(?<foo>.)/.named_captures
# => {"foo"=>[1, 2]}

# 名前付きキャプチャを持たないときは空の Hash を返します。
/(.)(.)/.named_captures
# => {}
//}...

Data#deconstruct_keys(array_of_names_or_nil) -> hash (8219.0)

self のメンバの名前と値の組を Hash で返します。

...self のメンバの名前と値の組を Hash で返します。

//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)

distance = Measure.new(10, 'km')
distance.deconstruct_keys(nil) # => {:amount=>10, :unit=>"km"}
distance.deconstruct_keys([:amount]) # => {:amount=>10}
//}

このメ...
...下のようにも書ける
case distance
in Measure(amount:, unit: 'km')
puts "It is #{amount} kilometers away"
# ...
end
//}

@param array_of_names_or_nil 返り値に含めるメンバの名前の配列を指定します。nil の場合は全てのメンバを意味します。

[注意] 本メ...

絞り込み条件を変える

ENV.to_h {|name, value| block } -> Hash (8217.0)

環境変数の名前をキーとし、対応する値をもつハッシュを返します。

...変数の名前をキーとし、対応する値をもつハッシュを返します。

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
ENV.to_h {|name, value| [name, value.size] }
//}...

Data#to_h -> Hash (8144.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...self のメンバ名(Symbol)と値の組を Hash にして返します。

//emlist[例][ruby]{
Customer = Data.define(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}

ブロックを...
...使います。
//emlist[ブロック付きの例][ruby]{
Customer = Data.define(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zi...

Data#to_h {|member, value| block } -> Hash (8144.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...self のメンバ名(Symbol)と値の組を Hash にして返します。

//emlist[例][ruby]{
Customer = Data.define(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}

ブロックを...
...使います。
//emlist[ブロック付きの例][ruby]{
Customer = Data.define(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zi...

Struct#to_h -> Hash (8144.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...self のメンバ名(Symbol)と値の組を Hash にして返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}

ブロックを...
...使います。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip...

Struct#to_h {|member, value| block } -> Hash (8144.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...self のメンバ名(Symbol)と値の組を Hash にして返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}

ブロックを...
...使います。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip...

絞り込み条件を変える

Struct#to_h -> Hash (8131.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...self のメンバ名(Symbol)と値の組を Hash にして返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}


[注意] 本メ...

Module#ruby2_keywords(method_name, ...) -> nil (8119.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.

...od 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 a...

ENV.to_h -> Hash (8117.0)

環境変数の名前をキーとし、対応する値をもつハッシュを返します。

...変数の名前をキーとし、対応する値をもつハッシュを返します。

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
ENV.to_h {|name, value| [name, value.size] }
//}...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) -> IO (8115.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...配列の場合は、シェルを経由せずに子プロセスを実行します。

シェルを経由しない場合(上のシグネチャで cmdname を含む場合)には *args
がサブプロセスの引数として使われます。この場合には *args はシェルでの
ワイルドカ...
...セスから得られる文字列を EUC-JP と指定する
# IO.new などと共通のオプションが指定できる
IO.popen("nkf -e filename", external_encoding: "EUC-JP"){|nkf_io|
nkf_io.read
}

これに加えて、プロセス起動のためのオプションを execopt で指定...
...d
}

@param env 環境変数を { 変数名 => 内容 } という形式の Hash で渡します。
@param command コマンド名を文字列で指定します。シェルを経由して実行されます。
@param cmdname コマンド名を文字列で指定します
@param arg0 みせかけの...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) {|f| ... } -> object (8115.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...配列の場合は、シェルを経由せずに子プロセスを実行します。

シェルを経由しない場合(上のシグネチャで cmdname を含む場合)には *args
がサブプロセスの引数として使われます。この場合には *args はシェルでの
ワイルドカ...
...セスから得られる文字列を EUC-JP と指定する
# IO.new などと共通のオプションが指定できる
IO.popen("nkf -e filename", external_encoding: "EUC-JP"){|nkf_io|
nkf_io.read
}

これに加えて、プロセス起動のためのオプションを execopt で指定...
...d
}

@param env 環境変数を { 変数名 => 内容 } という形式の Hash で渡します。
@param command コマンド名を文字列で指定します。シェルを経由して実行されます。
@param cmdname コマンド名を文字列で指定します
@param arg0 みせかけの...

絞り込み条件を変える

IO.popen([env = {}, cmdname, *args, execopt={}], mode = "r", opt={}) -> IO (8115.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...配列の場合は、シェルを経由せずに子プロセスを実行します。

シェルを経由しない場合(上のシグネチャで cmdname を含む場合)には *args
がサブプロセスの引数として使われます。この場合には *args はシェルでの
ワイルドカ...
...セスから得られる文字列を EUC-JP と指定する
# IO.new などと共通のオプションが指定できる
IO.popen("nkf -e filename", external_encoding: "EUC-JP"){|nkf_io|
nkf_io.read
}

これに加えて、プロセス起動のためのオプションを execopt で指定...
...d
}

@param env 環境変数を { 変数名 => 内容 } という形式の Hash で渡します。
@param command コマンド名を文字列で指定します。シェルを経由して実行されます。
@param cmdname コマンド名を文字列で指定します
@param arg0 みせかけの...
<< 1 2 > >>