Sha256: c00e6b19fa51de38e9b4a0e9a28a150249b59d69d1870e70d7a0aa856b560b29

Contents?: true

Size: 979 Bytes

Versions: 216

Compression:

Stored size: 979 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

    def length
      all.length
    end

    alias_method :size, :length

    private

    def all
      @all ||= slugs.map { |slug|
        Implementation.new(track, Specification.new(slug, root, track))
      }
    end

    def by_slug
      @by_slug ||= implementation_map
    end

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

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.180 lib/trackler/implementations.rb
trackler-2.2.1.179 lib/trackler/implementations.rb
trackler-2.2.1.178 lib/trackler/implementations.rb
trackler-2.2.1.177 lib/trackler/implementations.rb
trackler-2.2.1.176 lib/trackler/implementations.rb
trackler-2.2.1.175 lib/trackler/implementations.rb
trackler-2.2.1.174 lib/trackler/implementations.rb
trackler-2.2.1.173 lib/trackler/implementations.rb
trackler-2.2.1.172 lib/trackler/implementations.rb
trackler-2.2.1.171 lib/trackler/implementations.rb
trackler-2.2.1.170 lib/trackler/implementations.rb
trackler-2.2.1.169 lib/trackler/implementations.rb
trackler-2.2.1.167 lib/trackler/implementations.rb
trackler-2.2.1.166 lib/trackler/implementations.rb
trackler-2.2.1.165 lib/trackler/implementations.rb
trackler-2.2.1.164 lib/trackler/implementations.rb
trackler-2.2.1.163 lib/trackler/implementations.rb
trackler-2.2.1.162 lib/trackler/implementations.rb
trackler-2.2.1.161 lib/trackler/implementations.rb
trackler-2.2.1.160 lib/trackler/implementations.rb