module Daru class Vector include Enumerable def each(&block) @vector.each(&block) end attr_reader :name attr_reader :size def initialize source, name=SecureRandom.uuid @name = source.is_a?(Hash) ? source.keys[0] : name @vector = if source.is_a? Hash source.values[0].is_a?(Range) ? source.values[0].to_a : source.values[0] elsif source.is_a? Range or source.is_a? Matrix source.to_a.flatten else source end @size = @vector.size end def [](index) @vector[index] end end end