Class: Array

Inherits:
Object show all
Defined in:
lib/bauk/utils/symbolize.rb,
lib/bauk/utils/array_utils.rb

Instance Method Summary collapse

Instance Method Details

#join_custom(map = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bauk/utils/array_utils.rb', line 4

def join_custom(map = {})
  map[:delim] ||= ', '
  map[:end_delim] ||= ' and '
  case length
  when 0
    ''
  when 1
    self[0].to_s.dup
  else
    "#{self[0...-1].join(map[:delim])}#{map[:end_delim]}#{self[-1]}"
  end
end

#symbolizeObject



18
19
20
21
22
# File 'lib/bauk/utils/symbolize.rb', line 18

def symbolize
  each_with_object([]) do |v, memo|
    memo.push v.respond_to?(:symbolize) ? v.symbolize() : v
  end
end