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



2
3
4
5
6
# File 'lib/core_ext/array_without_blank.rb', line 2

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

Instance Method Details

#+(other_ary) ⇒ Object



34
35
36
# File 'lib/core_ext/array_without_blank.rb', line 34

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

#<<(obj) ⇒ Object



38
39
40
41
# File 'lib/core_ext/array_without_blank.rb', line 38

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

#[]=(index, obj) ⇒ Object



25
26
27
28
# File 'lib/core_ext/array_without_blank.rb', line 25

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

#concat(other_ary) ⇒ Object



30
31
32
# File 'lib/core_ext/array_without_blank.rb', line 30

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

#initialize_copy(other_ary) ⇒ Object



8
9
10
# File 'lib/core_ext/array_without_blank.rb', line 8

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

#insert(*args) ⇒ Object



21
22
23
# File 'lib/core_ext/array_without_blank.rb', line 21

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

#push(obj, *smth) ⇒ Object



16
17
18
19
# File 'lib/core_ext/array_without_blank.rb', line 16

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

#replace(other_ary) ⇒ Object



12
13
14
# File 'lib/core_ext/array_without_blank.rb', line 12

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

#to_aryObject



43
44
45
# File 'lib/core_ext/array_without_blank.rb', line 43

def to_ary
  Array.new(self)
end