Sha256: abcc560b9c55960a6330e6516fb0c7724aa8ca95dbf16f69a58bf7a030fe829d

Contents?: true

Size: 548 Bytes

Versions: 17

Compression:

Stored size: 548 Bytes

Contents

module USaidWat
  module Algorithms
    class Algorithm
      attr_reader :buckets

      def initialize(buckets)
        @buckets = buckets
      end

      def sort(a, b)
        a <=> b
      end
    end

    class LexicographicalAlgorithm < Algorithm
      def sort(a, b)
        a.downcase <=> b.downcase
      end
    end

    class CountAlgorithm < Algorithm
      def sort(a, b)
        if buckets[a] == buckets[b]
          a.downcase <=> b.downcase
        else
          buckets[b] <=> buckets[a]
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
usaidwat-1.6.1 lib/usaidwat/algo.rb
usaidwat-1.6.0 lib/usaidwat/algo.rb
usaidwat-1.5.1 lib/usaidwat/algo.rb
usaidwat-1.5.0 lib/usaidwat/algo.rb
usaidwat-1.4.5 lib/usaidwat/algo.rb
usaidwat-1.4.4 lib/usaidwat/algo.rb
usaidwat-1.4.3 lib/usaidwat/algo.rb
usaidwat-1.4.2 lib/usaidwat/algo.rb
usaidwat-1.4.1 lib/usaidwat/algo.rb
usaidwat-1.4.0 lib/usaidwat/algo.rb
usaidwat-1.3.0 lib/usaidwat/algo.rb
usaidwat-1.2.0 lib/usaidwat/algo.rb
usaidwat-1.1.1 lib/usaidwat/algo.rb
usaidwat-1.1.0 lib/usaidwat/algo.rb
usaidwat-1.0.1 lib/usaidwat/algo.rb
usaidwat-1.0.0 lib/usaidwat/algo.rb
usaidwat-0.1.7 lib/usaidwat/algo.rb