るりまサーチ (Ruby 2.7.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.043秒)
トップページ > クエリ:-[x] > クエリ:on[x] > クラス:Struct[x] > バージョン:2.7.0[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

キーワード

検索結果

Struct#deconstruct -> [object] (18604.0)

構造体のメンバの値を配列にいれて返します。

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

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

@see d:spec/pattern_matching#matching_non_primitive_objects...

Struct#deconstruct_keys(array_of_names) -> Hash (18604.0)

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

...ustomer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
h = joe.deconstruct_keys([:zip, :address])
h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"}

# 引数が nil の場合は全てのメンバを返します。
h = joe.deconstruct_keys(ni...
...:address=>"123 Maple, Anytown NC", :zip=>12345}
//}

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

@see d:spec/patter...

Struct#to_json(*args) -> String (18604.0)

自身を JSON 形式の文字列に変換して返します。

...引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。

//emlist[例][ruby]{
require "json/add/core"

Person = Struct.new(:name, :age)
Person.new("tanaka", 29).to_json # => "{\"json_class\":\"Person\",\"v\":[\"tanaka\",29]}"
//}

@see JSON::Generator::GeneratorMe...

Struct.json_create(hash) -> Struct (18604.0)

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

@param hash 適切なキーを持つハッシュを指定します。

Struct#to_a -> [object] (9304.0)

構造体のメンバの値を配列にいれて返します。

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

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

@see d:spec/pattern_matching#matching_non_primitive_objects...

絞り込み条件を変える

Struct#values -> [object] (9304.0)

構造体のメンバの値を配列にいれて返します。

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

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

@see d:spec/pattern_matching#matching_non_primitive_objects...