るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.025秒)
トップページ > クエリ:new[x] > クエリ:Struct[x] > クエリ:yaml/store[x]

別のキーワード

  1. struct new
  2. mkmf have_struct_member
  3. struct members
  4. struct each_pair
  5. struct select

検索結果

yaml/store (38048.0)

RubyのオブジェクトをYAML形式の外部ファイルに格納するためのクラスです。

...ァイルに格納するためのクラスです。

例:

require 'yaml/store'

Person = Struct.new :first_name, :last_name

people = [Person.new("Bob", "Smith"), Person.new("Mary", "Johnson")]

store = YAML::Store.new "test.store"

store.transaction do
store["people"] = people
st...
...] = { "hello" => "world" }
end

上記のコードを実行すると "test.store" は以下のようになります。

---
people:
- !ruby/struct:Person
first_name: Bob
last_name: Smith
- !ruby/struct:Person
first_name: Mary
last_name: Johnson
greeting:
hello: world...