class Struct
Public Instance Methods
dig(key, *rest)
click to toggle source
# File lib/backports/2.3.0/struct/dig.rb, line 3 def dig(key, *rest) return nil unless respond_to?(key) val = self.public_send(key) return val if rest.empty? || val == nil raise TypeError, "#{val.class} does not have #dig method" unless val.respond_to? :dig val.dig(*rest) end
to_h()
click to toggle source
# File lib/backports/2.0.0/struct/to_h.rb, line 3 def to_h h = {} self.class.members.each{|m| h[m.to_sym] = self[m]} h end