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.6.25 lib/trackler/implementations.rb
trackler-2.0.6.24 lib/trackler/implementations.rb
trackler-2.0.6.23 lib/trackler/implementations.rb
trackler-2.0.6.22 lib/trackler/implementations.rb
trackler-2.0.6.21 lib/trackler/implementations.rb
trackler-2.0.6.20 lib/trackler/implementations.rb
trackler-2.0.6.19 lib/trackler/implementations.rb
trackler-2.0.6.18 lib/trackler/implementations.rb
trackler-2.0.6.17 lib/trackler/implementations.rb
trackler-2.0.6.16 lib/trackler/implementations.rb
trackler-2.0.6.15 lib/trackler/implementations.rb
trackler-2.0.6.14 lib/trackler/implementations.rb
trackler-2.0.6.13 lib/trackler/implementations.rb
trackler-2.0.6.12 lib/trackler/implementations.rb
trackler-2.0.6.11 lib/trackler/implementations.rb
trackler-2.0.6.10 lib/trackler/implementations.rb
trackler-2.0.6.9 lib/trackler/implementations.rb
trackler-2.0.6.8 lib/trackler/implementations.rb
trackler-2.0.6.7 lib/trackler/implementations.rb
trackler-2.0.6.6 lib/trackler/implementations.rb