Top Level Namespace

Defined Under Namespace

Modules: TypedArray

Instance Method Summary collapse

Instance Method Details

#TypedArray(*types_allowed) ⇒ Object

Provide a factory method. Takes any number of types to accept as arguments and returns a class that behaves as a type-enforced array.



67
68
69
70
71
72
73
74
75
76
# File 'lib/typed-array.rb', line 67

def TypedArray *types_allowed
  klass = Class.new( Array )
  klass.class_exec(types_allowed) do |types_allowed|
    extend TypedArray
    restricted_types *types_allowed
    restricted_types
  end
  klass.restricted_types
  klass
end