Method: StructWithType.new
- Defined in:
- lib/langhelp/langhelp-sub.rb
.new(*args) ⇒ Object
TODO: document
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
# File 'lib/langhelp/langhelp-sub.rb', line 632 def self.new(*args) keys = [] types = [] args.each_with_index do |x,i| if i%2 == 0 keys << x else types << x end end unless keys.length > 0 && types.length > 0 && keys.length == types.length raise ArgumentError, "#{self}: args.length must be even" end klass = super(*keys) klass.instance_eval do @@__type_dic__ = {} @@__keys__ = keys keys.each_with_index{|k,i| @@__type_dic__[k] = types[i]} end klass end |