Class: Kuby::Docker::PackageList
- Inherits:
-
Object
- Object
- Kuby::Docker::PackageList
- Includes:
- Enumerable
- Defined in:
- lib/kuby/docker/package_list.rb
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(T::Array) }.
Instance Method Summary collapse
-
#[](name) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: Symbol).returns(T.nilable(Distro::PackageImpl)) }.
-
#add(name, version = nil) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }.
-
#delete(name) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: String).void }.
-
#each(&block) ⇒ Object
T::Sig::WithoutRuntime.sig { override.params( block: T.proc.params(package: Distro::PackageImpl).void ) .void }.
-
#empty? ⇒ Boolean
T::Sig::WithoutRuntime.sig { returns(T::Boolean) }.
-
#initialize(package_tuples) ⇒ PackageList
constructor
T::Sig::WithoutRuntime.sig { params(package_tuples: T::Array[[Symbol, T.nilable(String)]]).void }.
Constructor Details
#initialize(package_tuples) ⇒ PackageList
T::Sig::WithoutRuntime.sig { params(package_tuples: T::Array[[Symbol, T.nilable(String)]]).void }
17 18 19 20 |
# File 'lib/kuby/docker/package_list.rb', line 17 def initialize(package_tuples) @packages = [] package_tuples.each { |name, version| add(name, version) } end |
Instance Attribute Details
#packages ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(T::Array) }
14 15 16 |
# File 'lib/kuby/docker/package_list.rb', line 14 def packages @packages end |
Instance Method Details
#[](name) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: Symbol).returns(T.nilable(Distro::PackageImpl)) }
23 24 25 |
# File 'lib/kuby/docker/package_list.rb', line 23 def [](name) packages.find { |pkg| pkg.name == name } end |
#add(name, version = nil) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }
28 29 30 |
# File 'lib/kuby/docker/package_list.rb', line 28 def add(name, version = nil) packages << Packages::Package.new(name, version) end |
#delete(name) ⇒ Object
T::Sig::WithoutRuntime.sig { params(name: String).void }
33 34 35 |
# File 'lib/kuby/docker/package_list.rb', line 33 def delete(name) packages.delete_if { |pkg| pkg.name == name } end |
#each(&block) ⇒ Object
T::Sig::WithoutRuntime.sig
override.params(
block: T.proc.params(package: Distro::PackageImpl).void
)
.void
43 44 45 |
# File 'lib/kuby/docker/package_list.rb', line 43 def each(&block) packages.each(&block) end |
#empty? ⇒ Boolean
T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
48 49 50 |
# File 'lib/kuby/docker/package_list.rb', line 48 def empty? packages.empty? end |