The functions that get included into TypedArray
Validates outcome. See Array#&
# File lib/typed-array/functions.rb, line 21 def & ary self.class.new super end
Validates outcome. See Array#*
# File lib/typed-array/functions.rb, line 26 def * int self.class.new super end
Validates outcome. See Array#+
# File lib/typed-array/functions.rb, line 31 def + ary self.class.new super end
Validates outcome. See Array#<<
# File lib/typed-array/functions.rb, line 36 def << item _ensure_item_is_allowed item super end
Validates outcome. See Array#[]
# File lib/typed-array/functions.rb, line 42 def [] idx self.class.new super end
Validates outcome. See Array#[]=
# File lib/typed-array/functions.rb, line 52 def []= idx, item _ensure_item_is_allowed item super end
Validates outcome. See Array#concat
# File lib/typed-array/functions.rb, line 58 def concat other_ary _ensure_all_items_in_array_are_allowed other_ary super end
Validates outcome. See Array#eql?
# File lib/typed-array/functions.rb, line 64 def eql? other_ary _ensure_all_items_in_array_are_allowed other_ary super end
Validates outcome. See Array#fill
# File lib/typed-array/functions.rb, line 70 def fill *args, &block ary = self.to_a ary.fill *args, &block self.replace ary end
Validates outcome. See Array#map!
# File lib/typed-array/functions.rb, line 89 def map! &block self.replace( self.map &block ) end
Validates outcome. See Array#push
# File lib/typed-array/functions.rb, line 77 def push *items _ensure_all_items_in_array_are_allowed items super end
Validates outcome. See Array#replace
# File lib/typed-array/functions.rb, line 15 def replace other_ary _ensure_all_items_in_array_are_allowed other_ary super end
Ensure that all items in the passed Array are allowed
# File lib/typed-array/functions.rb, line 96 def _ensure_all_items_in_array_are_allowed ary # If we're getting an instance of self, accept return true if ary.is_a? self.class _ensure_item_is_allowed( ary, [Array] ) ary.each do |item| _ensure_item_is_allowed(item) end end
Ensure that the specific item passed is allowed
# File lib/typed-array/functions.rb, line 106 def _ensure_item_is_allowed item, expected=nil return true if item.nil? #allow nil entries expected = self.class.restricted_types if expected.nil? expected.each do |allowed| return true if item.class <= allowed end raise TypedArray::UnexpectedTypeException.new expected, item.class end
Generated with the Darkfish Rdoc Generator 2.