Class: Array

Inherits:
Object show all
Defined in:
lib/trax/core/ext/array.rb

Instance Method Summary collapse

Instance Method Details

#flat_compact_uniq!Object Also known as: flatten_compact_uniq!



15
16
17
18
19
20
# File 'lib/trax/core/ext/array.rb', line 15

def flat_compact_uniq!
  self.flatten!
  self.compact!
  self.uniq!
  self
end

#to_procObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/trax/core/ext/array.rb', line 3

def to_proc
  ->(hash_or_object) {
    if hash_or_object.is_a?(::Hash)
      length == 1 ? hash_or_object[first] : hash_or_object.values_at(*self)
    else
      length == 1 ? hash_or_object.__send__(first) : self.each_with_object({}){ |method_name,result|
                                                       result[method_name] = hash_or_object.__send__(method_name)
                                                     }
    end
  }
end

#to_single_quoted_listObject



23
24
25
# File 'lib/trax/core/ext/array.rb', line 23

def to_single_quoted_list
  "\'#{self.join("', '")}\'"
end