Class: ArrayWithoutBlank

Inherits:
Array
  • Object
show all
Defined in:
lib/core_ext/array_without_blank.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*several_variants) ⇒ Object



4
5
6
7
8
# File 'lib/core_ext/array_without_blank.rb', line 4

def self.new(*several_variants)
  arr = super
  arr.reject!(&:blank?)
  arr
end

Instance Method Details

#+(other_ary) ⇒ Object



36
37
38
# File 'lib/core_ext/array_without_blank.rb', line 36

def +(other_ary)
  super other_ary.reject(&:blank?)
end

#<<(obj) ⇒ Object



40
41
42
43
# File 'lib/core_ext/array_without_blank.rb', line 40

def <<(obj)
  return self if obj.blank?
  super
end

#[]=(index, obj) ⇒ Object



27
28
29
30
# File 'lib/core_ext/array_without_blank.rb', line 27

def []=(index, obj)
  return self[index] if obj.blank?
  super
end

#concat(other_ary) ⇒ Object



32
33
34
# File 'lib/core_ext/array_without_blank.rb', line 32

def concat(other_ary)
  super other_ary.reject(&:blank?)
end

#initialize_copy(other_ary) ⇒ Object



10
11
12
# File 'lib/core_ext/array_without_blank.rb', line 10

def initialize_copy(other_ary)
  super other_ary.reject(&:blank?)
end

#insert(*args) ⇒ Object



23
24
25
# File 'lib/core_ext/array_without_blank.rb', line 23

def insert(*args)
  super(*args.reject(&:blank?))
end

#push(obj, *smth) ⇒ Object



18
19
20
21
# File 'lib/core_ext/array_without_blank.rb', line 18

def push(obj, *smth)
  return self if obj.blank?
  super
end

#replace(other_ary) ⇒ Object



14
15
16
# File 'lib/core_ext/array_without_blank.rb', line 14

def replace(other_ary)
  super other_ary.reject(&:blank?)
end

#to_aryObject



45
46
47
# File 'lib/core_ext/array_without_blank.rb', line 45

def to_ary
  Array.new(self)
end