Class: Array
Instance Method Summary collapse
- #flat_compact_uniq! ⇒ Object (also: #flatten_compact_uniq!)
-
#to_proc ⇒ Object
inspired by: thepugautomatic.com/2014/11/array-to-proc-for-hash-access/.
- #to_single_quoted_list ⇒ Object
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_proc ⇒ Object
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_list ⇒ Object
23 24 25 |
# File 'lib/trax/core/ext/array.rb', line 23 def to_single_quoted_list "\'#{self.join("', '")}\'" end |