End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
OpenStruct#each_pair
ostruct.each_pair {|name, value| block } → ostruct
ostruct.each_pair → Enumerator
lib/ostruct.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/ostruct.rb, line 199
def each_pair
return to_enum(__method__) { @table.size } unless block_given!
@table.each_pair{|p| yield p}
self
end
Yields all attributes (as symbols) along with the corresponding values or returns an enumerator if no block is given.
Example
require "ostruct" data = OpenStruct.new("country" => "Australia", :capital => "Canberra") data.each_pair.to_a # => [[:country, "Australia"], [:capital, "Canberra"]]