Module: ValidArray::Functions
- Defined in:
- lib/valid-array/functions.rb
Overview
The functions that get included into ValidArray
Instance Method Summary collapse
-
#&(ary) ⇒ Object
Validates outcome.
-
#*(int) ⇒ Object
Validates outcome.
-
#+(ary) ⇒ Object
Validates outcome.
-
#<<(item) ⇒ Object
Validates outcome.
-
#[](idx) ⇒ Object
Validates outcome.
-
#[]=(idx, item) ⇒ Object
Validates outcome.
-
#concat(other_ary) ⇒ Object
Validates outcome.
-
#fill(*args, &block) ⇒ Object
Validates outcome.
-
#initialize(*args, &block) ⇒ Object
Validates outcome.
-
#map!(&block) ⇒ Object
Validates outcome.
-
#push(*items) ⇒ Object
Validates outcome.
-
#replace(other_ary) ⇒ Object
Validates outcome.
-
#slice(*args) ⇒ Object
Validates outcome.
-
#unshift(*items) ⇒ Object
Validates outcome.
Instance Method Details
#&(ary) ⇒ Object
Validates outcome. See Array#&
21 22 23 |
# File 'lib/valid-array/functions.rb', line 21 def &(ary) self.class.new super end |
#*(int) ⇒ Object
Validates outcome. See Array#*
26 27 28 |
# File 'lib/valid-array/functions.rb', line 26 def *(int) self.class.new super end |
#+(ary) ⇒ Object
Validates outcome. See Array#+
31 32 33 |
# File 'lib/valid-array/functions.rb', line 31 def +(ary) self.class.new super end |
#<<(item) ⇒ Object
Validates outcome. See Array#<<
36 37 38 39 |
# File 'lib/valid-array/functions.rb', line 36 def <<(item) item = self.class.validate item super end |
#[](idx) ⇒ Object
Validates outcome. See Array#[]
42 43 44 |
# File 'lib/valid-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/valid-array/functions.rb', line 52 def []=(idx, item) item = self.class.validate item super end |
#concat(other_ary) ⇒ Object
Validates outcome. See Array#concat
58 59 60 61 |
# File 'lib/valid-array/functions.rb', line 58 def concat(other_ary) _ensure_array_is_valid other_ary super end |
#fill(*args, &block) ⇒ Object
Validates outcome. See Array#fill
70 71 72 73 74 |
# File 'lib/valid-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/valid-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!
91 92 93 |
# File 'lib/valid-array/functions.rb', line 91 def map!(&block) self.replace(self.map &block) end |
#push(*items) ⇒ Object
Validates outcome. See Array#push
77 78 79 80 81 |
# File 'lib/valid-array/functions.rb', line 77 def push(*items) items = items.dup _ensure_array_is_valid items super end |
#replace(other_ary) ⇒ Object
Validates outcome. See Array#replace
15 16 17 18 |
# File 'lib/valid-array/functions.rb', line 15 def replace(other_ary) _ensure_array_is_valid other_ary super end |
#slice(*args) ⇒ Object
Validates outcome. See Array#slice
47 48 49 |
# File 'lib/valid-array/functions.rb', line 47 def slice(*args) self.class.new super end |
#unshift(*items) ⇒ Object
Validates outcome. See Array#unshift
84 85 86 87 88 |
# File 'lib/valid-array/functions.rb', line 84 def unshift(*items) items = items.dup _ensure_array_is_valid items super end |