new(hash=nil)
Class Public methods
Creates a new OpenStruct object. By default, the resulting OpenStruct object will have no attributes.
The optional hash
, if given, will generate attributes and
values (can be a Hash, an OpenStruct or a Struct). For example:
require 'ostruct' hash = { "country" => "Australia", :population => 20_000_000 } data = OpenStruct.new(hash) p data # -> <OpenStruct country="Australia" population=20000000>
Please login to continue.