Sha256: f1236627539af21dace3970e663e98459a5eb0b3c7a5e9006ee548defab9573c
Contents?: true
Size: 589 Bytes
Versions: 2
Compression:
Stored size: 589 Bytes
Contents
require 'ostruct' module Flextures module Extensions module Array # use Object#extend # @params [Array] keys hash keys # @return [Hash] tanslated Hash data # example: # hash = array.extend(Extensions::Array).to_hash(keys) def to_hash(keys) values = self values = values[0..keys.size-1] if keys.size < values.size values = values+[nil]*(keys.size-values.size) if keys.size > values.size [keys,values].transpose.reduce({}){ |h,pair| k,v=pair; h[k]=v; h } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flextures-4.0.1 | lib/flextures/flextures_extension_modules.rb |
flextures-4.0.0 | lib/flextures/flextures_extension_modules.rb |