Class: Array

Inherits:
Object show all
Defined in:
lib/core_extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#exclude?(value) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/core_extensions/array.rb', line 14

def exclude?(value)
  !include?(value)
end

#map_to(field) ⇒ Object



10
11
12
# File 'lib/core_extensions/array.rb', line 10

def map_to(field)
  self.map { |hash| hash[field] }
end

#to_dataObject



6
7
8
# File 'lib/core_extensions/array.rb', line 6

def to_data
  map(&:to_h)
end

#to_hObject



2
3
4
# File 'lib/core_extensions/array.rb', line 2

def to_h
  Hash[self]
end

#to_hash_with_indexes_as_keysObject



18
19
20
# File 'lib/core_extensions/array.rb', line 18

def to_hash_with_indexes_as_keys
  each_with_index.map { |option,index| [index,option] }.to_h
end