class FieldedArray
proxy class that allows an array to be wrapped in a way that still allows # keyword access. also facilitate usage of ArrayFields with arraylike objects. thnx to Sean O'Dell for the suggestion.
sample usage
Public Class Methods
new(fields = [], array = [])
click to toggle source
# File lib/arrayfields.rb, line 399 def initialize fields = [], array = [] @a = array self.fields = fields end
Public Instance Methods
[](*pairs)
click to toggle source
# File lib/arrayfields.rb, line 388 def [](*pairs) pairs.flatten! raise ArgumentError, "argument must be key/val pairs" unless (pairs.size % 2 == 0) fields, elements = [], [] while((f = pairs.shift) and (e = pairs.shift)) fields << f and elements << e end new fields, elements end
method_missing(meth, *args, &block)
click to toggle source
# File lib/arrayfields.rb, line 403 def method_missing(meth, *args, &block) @a.send(meth, *args, &block) end