Sha256: 51def2b6d143ec367b50ec787179f6fafab5c50117b038a63afab09c97c5ad5c

Contents?: true

Size: 901 Bytes

Versions: 20

Compression:

Stored size: 901 Bytes

Contents

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

    attr_reader :repo, :slugs, :root, :track
    def initialize(repo, slugs, root, track)
      @repo = repo
      @slugs = slugs
      @root = root
      @track = track
    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, Problem.new(slug, root, track))
      }
    end

    def by_slug
      @by_slug ||= implementation_map
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
trackler-2.1.0.18 lib/trackler/implementations.rb
trackler-2.1.0.17 lib/trackler/implementations.rb
trackler-2.1.0.16 lib/trackler/implementations.rb
trackler-2.1.0.15 lib/trackler/implementations.rb
trackler-2.1.0.14 lib/trackler/implementations.rb
trackler-2.1.0.13 lib/trackler/implementations.rb
trackler-2.1.0.12 lib/trackler/implementations.rb
trackler-2.1.0.11 lib/trackler/implementations.rb
trackler-2.1.0.10 lib/trackler/implementations.rb
trackler-2.1.0.9 lib/trackler/implementations.rb
trackler-2.1.0.8 lib/trackler/implementations.rb
trackler-2.1.0.7 lib/trackler/implementations.rb
trackler-2.1.0.6 lib/trackler/implementations.rb
trackler-2.1.0.5 lib/trackler/implementations.rb
trackler-2.1.0.4 lib/trackler/implementations.rb
trackler-2.1.0.3 lib/trackler/implementations.rb
trackler-2.1.0.2 lib/trackler/implementations.rb
trackler-2.1.0.1 lib/trackler/implementations.rb
trackler-2.1.0.0 lib/trackler/implementations.rb
trackler-2.0.8.55 lib/trackler/implementations.rb