Method: OpenStruct#each_pair
- Defined in:
- lib/ostruct.rb
#each_pair ⇒ Object
Yields all attributes (as a symbol) along with the corresponding values or returns an enumerator if not block is given. Example:
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :population => 20_000_000)
data.each_pair.to_a # => [[:country, "Australia"], [:population, 20000000]]
127 128 129 130 |
# File 'lib/ostruct.rb', line 127 def each_pair return to_enum(__method__) { @table.size } unless block_given? @table.each_pair{|p| yield p} end |