File: kwarg_struct.rb

package info (click to toggle)
ruby-countries 4.2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,196 kB
  • sloc: ruby: 2,085; makefile: 4
file content (12 lines) | stat: -rw-r--r-- 290 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
module ISO3166
  class KwargStruct < Struct
    # Override the initialize to handle hashes of named parameters
    def initialize(*args)
      opts = args.last.is_a?(Hash) ? args.pop : {}
      super(*args)
      opts.each_pair do |k, v|
        send "#{k}=", v
      end
    end
  end
end