2件ヒット
[1-2件を表示]
(0.106秒)
別のキーワード
ライブラリ
- ビルトイン (1)
-
json
/ add / struct (1)
検索結果
-
Struct
# to _ json(*args) -> String (307.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
# values _ at(*members) -> [object] (307.0) -
引数で指定されたメンバの値の配列を返します。
...]{
Foo = Struct.new(:foo, :bar, :baz)
obj = Foo.new('FOO', 'BAR', 'BAZ')
p obj.values_at(0, 1, 2) # => ["FOO", "BAR", "BAZ"]
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下...