[Ruby] class OpenStruct
ruby の OpenStruct クラス。
要素を動的に追加・削除できる手軽な構造体を提供するクラスです。
[1] pry(main)> son = OpenStruct.new({ :name => "Thomas", :age => 3 })
=> #<openStruct name="Thomas", age=3>
[2] pry(main)> son.name
=> "Thomas"
[3] pry(main)> son.age
=> 3
[4] pry(main)> son.age += 1
=> 4
[5] pry(main)> son.items = ["candy","toy"]
=> ["candy", "toy"]
[6] pry(main)> son
=> #<openStruct name="Thomas", age=4, items=["candy", "toy"]>