method

to_h

Importance_1
v2_5_5 - Show latest stable - 0 notes - Class: OpenStruct
to_h() public

Converts the OpenStruct to a hash with keys representing each attribute (as symbols) and their corresponding values.

require "ostruct"
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h   # => {:country => "Australia", :capital => "Canberra" }
Show source
Register or log in to add new notes.