lib/mwk-ruby-utils.rb in mwk-ruby-utils-0.1.0 vs lib/mwk-ruby-utils.rb in mwk-ruby-utils-0.2.0
- old
+ new
@@ -1,5 +1,14 @@
class Array
- def present_join(delim=", ")
- self.select {|x| (x || '').strip != ""}.join(delim)
+ def present_join(in_delim=", ")
+ self.select {|x| (x || '').strip != ""}.join(in_delim)
end
-end
\ No newline at end of file
+
+ def hashify_single(in_sym=nil)
+ res = {}
+ self.each do |iter_el|
+ res[in_sym.nil? ? iter_el : iter_el.send(in_sym)] = iter_el
+ end
+ res
+ end
+end
+