Sha256: df7506dc5eaa37dd3899dc24127add554b908598e6b38b41e451ac27d6e2393e

Contents?: true

Size: 1.26 KB

Versions: 23

Compression:

Stored size: 1.26 KB

Contents

# typed: strict

module Kuby
  module Docker
    class PackageList
      extend T::Sig
      extend T::Generic

      Elem = type_member(fixed: Distro::PackageImpl)

      include Enumerable

      sig { returns(T::Array[Distro::PackageImpl]) }
      attr_reader :packages

      sig { params(package_tuples: T::Array[[Symbol, T.nilable(String)]]).void }
      def initialize(package_tuples)
        @packages = T.let([], T::Array[Distro::PackageImpl])
        package_tuples.each { |name, version| add(name, version) }
      end

      sig { params(name: Symbol).returns(T.nilable(Distro::PackageImpl)) }
      def [](name)
        packages.find { |pkg| pkg.name == name }
      end

      sig { params(name: Symbol, version: T.nilable(String)).void }
      def add(name, version = nil)
        packages << Packages::Package.new(name, version)
      end

      sig { params(name: String).void }
      def delete(name)
        packages.delete_if { |pkg| pkg.name == name }
      end

      sig {
        override.params(
          block: T.proc.params(package: Distro::PackageImpl).void
        )
        .void
      }
      def each(&block)
        packages.each(&block)
      end

      sig { returns(T::Boolean) }
      def empty?
        packages.empty?
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
kuby-core-0.17.0 lib/kuby/docker/package_list.rb
kuby-core-0.16.1 lib/kuby/docker/package_list.rb
kuby-core-0.16.0 lib/kuby/docker/package_list.rb
kuby-core-0.15.0 lib/kuby/docker/package_list.rb
kuby-core-0.14.0 lib/kuby/docker/package_list.rb
kuby-core-0.13.0 lib/kuby/docker/package_list.rb
kuby-core-0.12.0 lib/kuby/docker/package_list.rb
kuby-core-0.11.16 lib/kuby/docker/package_list.rb
kuby-core-0.11.15 lib/kuby/docker/package_list.rb
kuby-core-0.11.14 lib/kuby/docker/package_list.rb
kuby-core-0.11.13 lib/kuby/docker/package_list.rb
kuby-core-0.11.12 lib/kuby/docker/package_list.rb
kuby-core-0.11.11 lib/kuby/docker/package_list.rb
kuby-core-0.11.10 lib/kuby/docker/package_list.rb
kuby-core-0.11.9 lib/kuby/docker/package_list.rb
kuby-core-0.11.8 lib/kuby/docker/package_list.rb
kuby-core-0.11.7 lib/kuby/docker/package_list.rb
kuby-core-0.11.6 lib/kuby/docker/package_list.rb
kuby-core-0.11.4 lib/kuby/docker/package_list.rb
kuby-core-0.11.3 lib/kuby/docker/package_list.rb