Sha256: 80f148543f0694926948e4ecc2d24c734eb7155b7bd973ad77f2176beae30f57
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
require 'arrayfields' # # the Arrayfields.new method is a contruct that takes evenly numbered pairs of # arbitrary objects and builds up and fielded array # a = Arrayfields.new :key, :value, :a, :b p a.fields #=> [:key, :a] p a.values #=> [:value, :b] # # you can use a hash - but of course the ordering gets lost in the initial # hash creation. aka the order of fields get horked by the unorderedness if # the hash iteration. it's okay for some purposed though # a = Arrayfields.new :key => :value, :a => :b p a.fields #=> [:key, :a] p a.values #=> [:value, :b] # # lists of pairs get flattened - the result simply has to be evenly numbered # a = Arrayfields.new [[:key, :value], [:a, :b]] p a.fields #=> [:key, :a] p a.values #=> [:value, :b] p a.pairs #=> [[:key, :value], [:a, :b]]
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
arrayfields-4.4.0 | sample/d.rb |
arrayfields-4.0.0 | sample/d.rb |
arrayfields-4.3.0 | sample/d.rb |
arrayfields-4.1.0 | sample/d.rb |
arrayfields-4.2.0 | sample/d.rb |