Sha256: 09066aac672d25c1854c7bba6b85a5e5579db6af4a94a2b901ffe734d3c9a58b

Contents?: true

Size: 469 Bytes

Versions: 1

Compression:

Stored size: 469 Bytes

Contents

module Ruborithms 
  module Algorithms
    module LinearSearch
      class << self
        def included(mod)
          mod.extend(ClassMethods)
        end

      end

      module ClassMethods
        def linear_search(object, value)
          object.each_with_index do |item, index|
            return index if value == item
          end
        end
      end

      def linear_search(value)
        self.class.linear_search(self, value)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruborithms-0.1.0 lib/ruborithms/algorithms/linear_search.rb