Module: TypedArray::Functions

Defined in:
lib/typed-array/functions.rb

Overview

The functions that get included into TypedArray

Instance Method Summary collapse

Instance Method Details

#&(ary) ⇒ Object

Validates outcome. See Array#&



21
22
23
# File 'lib/typed-array/functions.rb', line 21

def & ary
  self.class.new super
end

#*(int) ⇒ Object

Validates outcome. See Array#*



26
27
28
# File 'lib/typed-array/functions.rb', line 26

def * int
  self.class.new super
end

#+(ary) ⇒ Object

Validates outcome. See Array#+



31
32
33
# File 'lib/typed-array/functions.rb', line 31

def + ary
  self.class.new super
end

#<<(item) ⇒ Object

Validates outcome. See Array#<<



36
37
38
39
# File 'lib/typed-array/functions.rb', line 36

def << item
  _ensure_item_is_allowed item
  super
end

#[](idx) ⇒ Object

Validates outcome. See Array#[]



42
43
44
# File 'lib/typed-array/functions.rb', line 42

def [] idx
  self.class.new super
end

#[]=(idx, item) ⇒ Object

Validates outcome. See Array#[]=



52
53
54
55
# File 'lib/typed-array/functions.rb', line 52

def []= idx, item
  _ensure_item_is_allowed item
  super
end

#concat(other_ary) ⇒ Object

Validates outcome. See Array#concat



58
59
60
61
# File 'lib/typed-array/functions.rb', line 58

def concat other_ary
  _ensure_all_items_in_array_are_allowed other_ary
  super
end

#eql?(other_ary) ⇒ Boolean

Validates outcome. See Array#eql?

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/typed-array/functions.rb', line 64

def eql? other_ary
  _ensure_all_items_in_array_are_allowed other_ary
  super
end

#fill(*args, &block) ⇒ Object

Validates outcome. See Array#fill



70
71
72
73
74
# File 'lib/typed-array/functions.rb', line 70

def fill *args, &block
  ary = self.to_a
  ary.fill *args, &block
  self.replace ary
end

#initialize(*args, &block) ⇒ Object

Validates outcome. See Array#initialize



9
10
11
12
# File 'lib/typed-array/functions.rb', line 9

def initialize *args, &block
  ary = Array.new *args, &block
  self.replace ary
end

#map!(&block) ⇒ Object

Validates outcome. See Array#map!



89
90
91
# File 'lib/typed-array/functions.rb', line 89

def map! &block
  self.replace( self.map &block )
end

#push(*items) ⇒ Object

Validates outcome. See Array#push



77
78
79
80
# File 'lib/typed-array/functions.rb', line 77

def push *items
  _ensure_all_items_in_array_are_allowed items
  super
end

#replace(other_ary) ⇒ Object

Validates outcome. See Array#replace



15
16
17
18
# File 'lib/typed-array/functions.rb', line 15

def replace other_ary
  _ensure_all_items_in_array_are_allowed other_ary
  super
end

#slice(*args) ⇒ Object

Validates outcome. See Array#slice



47
48
49
# File 'lib/typed-array/functions.rb', line 47

def slice *args
  self.class.new super
end

#unshift(*items) ⇒ Object

Validates outcome. See Array#unshift



83
84
85
86
# File 'lib/typed-array/functions.rb', line 83

def unshift *items
  _ensure_all_items_in_array_are_allowed items
  super
end