File: to_h.rb

package info (click to toggle)
ruby-backports 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,460 kB
  • ctags: 703
  • sloc: ruby: 6,195; makefile: 24
file content (9 lines) | stat: -rw-r--r-- 160 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
unless Struct.method_defined? :to_h
  class Struct
    def to_h
      h = {}
      self.class.members.each{|m| h[m.to_sym] = self[m]}
      h
    end
  end
end