6 if Object.const_defined?(:Struct)
10 # Calls the given block for each element of +self+
11 # and pass the respective element.
15 self.class.members.each{|field|
16 block.call(self[field])
22 # Calls the given block for each element of +self+
23 # and pass the name and value of the respectiev
28 self.class.members.each{|field|
29 block.call(field.to_sym, self[field])
35 # Calls the given block for each element of +self+
36 # and returns an array with all elements of which
42 self.class.members.each{|field|
44 ary.push(val) if block.call(val)
50 name = self.class.to_s
54 str = "#<struct #{name} "
57 self.each_pair do |k,v|
58 buf.push [k.to_s + "=" + v._inspect]
60 str + buf.join(", ") + ">"
65 # struct.to_s -> string
66 # struct.inspect -> string
68 # Describe the contents of this struct in a string.
75 rescue SystemStackError
76 "#<struct #{self.class.to_s}:...>"
87 # hsh.dig(key,...) -> object
89 # Extracts the nested value specified by the sequence of <i>key</i>
90 # objects by calling +dig+ at each step, returning +nil+ if any
91 # intermediate step is +nil+.