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.7.0 lib/trackler/implementations.rb
trackler-2.0.6.44 lib/trackler/implementations.rb
trackler-2.0.6.43 lib/trackler/implementations.rb
trackler-2.0.6.42 lib/trackler/implementations.rb
trackler-2.0.6.41 lib/trackler/implementations.rb
trackler-2.0.6.40 lib/trackler/implementations.rb
trackler-2.0.6.39 lib/trackler/implementations.rb
trackler-2.0.6.38 lib/trackler/implementations.rb
trackler-2.0.6.37 lib/trackler/implementations.rb
trackler-2.0.6.36 lib/trackler/implementations.rb
trackler-2.0.6.35 lib/trackler/implementations.rb
trackler-2.0.6.34 lib/trackler/implementations.rb
trackler-2.0.6.33 lib/trackler/implementations.rb
trackler-2.0.6.32 lib/trackler/implementations.rb
trackler-2.0.6.31 lib/trackler/implementations.rb
trackler-2.0.6.30 lib/trackler/implementations.rb
trackler-2.0.6.29 lib/trackler/implementations.rb
trackler-2.0.6.28 lib/trackler/implementations.rb
trackler-2.0.6.27 lib/trackler/implementations.rb
trackler-2.0.6.26 lib/trackler/implementations.rb