module Rdoba::Mixin::To_hArray
Public Instance Methods
to_h(options = {})
click to toggle source
# File lib/rdoba/mixin.rb, line 208 def to_h options = {} h = {} self.each do |v| if v.is_a? Array if h.key? v[ 0 ] if !h[ v[ 0 ] ].is_a? Array h[ v[ 0 ] ] = [ h[ v[ 0 ] ] ] ; end if v.size > 2 h[ v [ 0 ] ].concat v[ 1..-1 ] else h[ v [ 0 ] ] << v[ 1 ] ; end else h[ v[ 0 ] ] = v.size > 2 && v[ 1..-1] || v[ 1 ] ; end else if h.key? v if !h[ v ].is_a? Array h[ v ] = [ h[ v ] ] ; end h[ v ] << v else h[ v ] = nil ; end ; end ; end if options[ :save_unique ] h.each_pair do |k,v| if v.is_a? Array v.uniq! ; end ; end ; end h ; end