Sha256: 5dc3fb33509f098319e7bb2477d093a931681c8d6bb034ca95f193cd8d6d74a8

Contents?: true

Size: 929 Bytes

Versions: 101

Compression:

Stored size: 929 Bytes

Contents

module Trackler
  # Implementations is a collection of exercises in a specific language track.
  class Implementations
    include Enumerable

    attr_reader :track_id, :repo, :slugs, :root
    def initialize(track_id, repo, slugs, root)
      @track_id = track_id
      @repo = repo
      @slugs = slugs
      @root = root
    end

    def each
      all.each do |implementation|
        yield implementation
      end
    end

    def [](slug)
      by_slug[slug]
    end

    private

    def all
      @all ||= slugs.map { |slug|
        Implementation.new(track_id, repo, Problem.new(slug, root), root)
      }
    end

    def by_slug
      @by_slug ||= implementation_map
    end

    def implementation_map
      hash = Hash.new { |_, k|
        Implementation.new(track_id, repo, Problem.new(k, root), root)
      }
      all.each do |impl|
        hash[impl.problem.slug] = impl
      end
      hash
    end
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
trackler-2.0.0.10 lib/trackler/implementations.rb
trackler-2.0.0.9 lib/trackler/implementations.rb
trackler-2.0.0.8 lib/trackler/implementations.rb
trackler-2.0.0.7 lib/trackler/implementations.rb
trackler-2.0.0.6 lib/trackler/implementations.rb
trackler-2.0.0.5 lib/trackler/implementations.rb
trackler-2.0.0.4 lib/trackler/implementations.rb
trackler-2.0.0.3 lib/trackler/implementations.rb
trackler-2.0.0.2 lib/trackler/implementations.rb
trackler-2.0.0.1 lib/trackler/implementations.rb
trackler-2.0.0.0 lib/trackler/implementations.rb
trackler-1.0.4.1 lib/trackler/implementations.rb
trackler-1.0.4.0 lib/trackler/implementations.rb
trackler-1.0.3.0 lib/trackler/implementations.rb
trackler-1.0.2.1 lib/trackler/implementations.rb
trackler-1.0.2.0 lib/trackler/implementations.rb
trackler-1.0.1.2 lib/trackler/implementations.rb
trackler-1.0.1.1 lib/trackler/implementations.rb
trackler-1.0.1.0 lib/trackler/implementations.rb
trackler-1.0.0.1 lib/trackler/implementations.rb