Class: Boxing::Package
- Inherits:
-
Object
- Object
- Boxing::Package
- Defined in:
- lib/boxing/package.rb
Overview
The rubygems mapping for Linux package
Constant Summary collapse
- RUNTIME =
0b01
- BUILD =
0b10
Instance Attribute Summary collapse
- #name ⇒ Object readonly
- #version ⇒ Object readonly
Class Method Summary collapse
-
.load(path) ⇒ Boxing::Package
Load Required Packages.
Instance Method Summary collapse
-
#build? ⇒ TrueClass|FalseClass
Is for build.
-
#eql?(other) ⇒ TrueClass|FalseClass
(also: #==)
Compare is same package.
-
#hash ⇒ Number
Return Object#hash.
-
#initialize(name, version = nil, mode: RUNTIME) ⇒ Package
constructor
A new instance of Package.
-
#runtime? ⇒ TrueClass|FalseClass
Is for runtime.
-
#to_s ⇒ String
Convert to string.
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
32 33 34 |
# File 'lib/boxing/package.rb', line 32 def name @name end |
#version ⇒ Object (readonly)
32 33 34 |
# File 'lib/boxing/package.rb', line 32 def version @version end |
Class Method Details
.load(path) ⇒ Boxing::Package
Load Required Packages
16 17 18 19 20 21 22 |
# File 'lib/boxing/package.rb', line 16 def load(path) data = YAML.safe_load(File.read(path)) mode = 0b00 mode |= Package::RUNTIME if data['runtime'] mode |= Package::BUILD if data['build'] new(data['name'], data['version'], mode: mode) end |
Instance Method Details
#build? ⇒ TrueClass|FalseClass
Returns is for build.
48 49 50 |
# File 'lib/boxing/package.rb', line 48 def build? @mode & BUILD == BUILD end |
#eql?(other) ⇒ TrueClass|FalseClass Also known as: ==
Compare is same package
64 65 66 |
# File 'lib/boxing/package.rb', line 64 def eql?(other) @name == other.name end |
#hash ⇒ Number
Return Object#hash
74 75 76 |
# File 'lib/boxing/package.rb', line 74 def hash @name.hash end |
#runtime? ⇒ TrueClass|FalseClass
Returns is for runtime.
55 56 57 |
# File 'lib/boxing/package.rb', line 55 def runtime? @mode & RUNTIME == RUNTIME end |
#to_s ⇒ String
Convert to string
83 84 85 86 87 88 |
# File 'lib/boxing/package.rb', line 83 def to_s return @name if @version.nil? # NOTE: Alpine format only "#{@name}=#{@version}" end |