Sha256: ab0032ba6fd1d085666b16ea97f1c50008100b216935ea399ed41f7c1b005042
Contents?: true
Size: 1.06 KB
Versions: 10
Compression:
Stored size: 1.06 KB
Contents
require 'arrayfields' # # the Arrayfields.new method is a contruct that takes evenly numbered pairs of # arbitrary objects and builds up a 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 of # ruby's hash iteration. it's okay for some purposes though # a = Arrayfields.new :key => :value, :a => :b p a.fields #=> [:key, :a] p a.values #=> [:value, :b] # # lists of pairs get flattened - the argument simply has to be evenly numbered # afterwards. # 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
10 entries across 10 versions & 2 rubygems