Elementor
Elementor is an Array which applies calls elementwise. Depending on the mode the call will return a new elementor, the same elementor, a new array, or the orignal array transformed.
Methods
Public Class methods
[ show source ]
# File lib/facets/more/elementor.rb, line 33 def initialize( an_array, mode=nil ) @array = an_array @mode = mode end
Public Instance methods
[ show source ]
# File lib/facets/more/elementor.rb, line 41 def each( *args, &block ) @array.each( *args, &block ) end
[ show source ]
# File lib/facets/more/elementor.rb, line 45 def method_missing( sym, *args, &block ) case @mode when :array @array.collect { |e| e.send( sym, *args, &block ) } when :inplace_array @array.collect! { |e| e.send( sym, *args, &block ) } @array when :inplace c = @array.collect { |e| e.send( sym, *args, &block ) } @array.replace( c ) self else c = @array.collect { |e| e.send( sym, *args, &block ) } self.__class__.new( c ) end end
[ show source ]
# File lib/facets/more/elementor.rb, line 38 def to_a ; @array ; end
[ show source ]
# File lib/facets/more/elementor.rb, line 39 def to_ary ; @array ; end