Sha256: ccdd3060db973924bf3eefa7a87a5cda7bfdd09f08c86d8bc5c974da5b9a26eb
Contents?: true
Size: 1.17 KB
Versions: 16
Compression:
Stored size: 1.17 KB
Contents
# Copyright (c) 2023 M.J.N. Corino, The Netherlands # # This software is released under the MIT license. # # Some parts are # Copyright 2004-2007, wxRuby development team # released under the MIT-like wxRuby2 license class Wx::AcceleratorTable # Allow new to be called as [] class << self alias :[] :new end # Allow initialize to be called with a splat-like list of arguments, # and allow entries to be specified in terser form [mod, key, id] # rather than full AcceleratorEntry.new call. wx_init = self.instance_method(:initialize) define_method(:initialize) do | *args | # Test for old-style arg passing in a single array if args.length == 1 and args.first.kind_of?(Array) and args.first.all? { | e | e.kind_of?(Wx::AcceleratorEntry) } args = args[0] end # Convert to array of AccEntries, to pass in as single array args = args.map do | entry | case entry when Wx::AcceleratorEntry then entry when Array then Wx::AcceleratorEntry.new(*entry) else Kernel.raise ArgumentError, "#{entry.inspect} is not a valid AcceleratorTable entry" end end wx_init.bind(self).call(args) end end
Version data entries
16 entries across 16 versions & 1 rubygems