Parent

Included Modules

Object::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

fa = FieldedArray.new %w(zero one two), [0,1,2] p fa #=> 0

Public Class Methods

[](*pairs) click to toggle source
# File lib/arrayfields.rb, line 397
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
new(fields = [], array = []) click to toggle source
# File lib/arrayfields.rb, line 408
def initialize fields = [], array = []
  @a = array
  self.fields = fields
end

Public Instance Methods

method_missing(meth, *args, &block) click to toggle source
# File lib/arrayfields.rb, line 412
def method_missing(meth, *args, &block)
  @a.send(meth, *args, &block)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.