Class: FieldedArray
- Includes:
- Fieldable
- Defined in:
- lib/main/arrayfields.rb,
lib/arrayfields.rb
Instance Attribute Summary
Attributes included from Fieldable
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(fields = [], array = []) ⇒ FieldedArray
constructor
A new instance of FieldedArray.
- #method_missing(meth, *args, &block) ⇒ Object
Methods included from Fieldable
Constructor Details
#initialize(fields = [], array = []) ⇒ FieldedArray
Returns a new instance of FieldedArray.
390 391 392 393 |
# File 'lib/main/arrayfields.rb', line 390 def initialize fields = [], array = [] @a = array self.fields = fields end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
394 395 396 |
# File 'lib/main/arrayfields.rb', line 394 def method_missing(meth, *args, &block) @a.send(meth, *args, &block) end |
Class Method Details
.[](*pairs) ⇒ Object
379 380 381 382 383 384 385 386 387 388 |
# File 'lib/main/arrayfields.rb', line 379 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 |