るりまサーチ

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

別のキーワード

  1. string []=
  2. string []
  3. string slice
  4. string slice!
  5. string gsub

ライブラリ

キーワード

検索結果

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

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

...SON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま 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::GeneratorMethods::Hash#to_json...

Struct#to_s -> String (3205.0)

self の内容を人間に読みやすい文字列にして返します。

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

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Sm...
...ith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"
//}...

Struct#inspect -> String (105.0)

self の内容を人間に読みやすい文字列にして返します。

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

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Sm...
...ith", "123 Maple, Anytown NC", 12345)
joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"
//}...