philiprehberger-bit_field 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +17 -0
- data/lib/philiprehberger/bit_field/version.rb +1 -1
- data/lib/philiprehberger/bit_field.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9177b0d13311c9ded1be36cd0b56b4d62c9fbad315c823f19437c9a8886a66c6
|
|
4
|
+
data.tar.gz: 2e2ed3c15bd4f7fa8e3426dd577e115d75825bc3dbbed2e624515ac0cc5bcc06
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfa1a00bbafef9ec7ad8bc658ea47ffd834e24456686b039efc478a88cf4cf3064a39fea76b583b7f3e52183cf06133c1ee1911a919e9aa23dab09e002664ad1
|
|
7
|
+
data.tar.gz: d409f6a964b1473b9dea05b3193e9ea5429dccd51c6c9944e8f9c51f819f148625e21d074204fc6fd1cc7cb46d1a157609dcffdff74103315729e680a91f3661
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.0] - 2026-05-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `BitField#disjoint?(other)` predicate returning `true` when self and `other` share zero flags in common — pairs with `subset_of?` for permission-isolation checks
|
|
14
|
+
- Card image to README per readme-template guide
|
|
15
|
+
|
|
10
16
|
## [0.7.0] - 2026-05-02
|
|
11
17
|
|
|
12
18
|
### Added
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
[](https://rubygems.org/gems/philiprehberger-bit_field)
|
|
5
5
|
[](https://github.com/philiprehberger/rb-bit-field/commits/main)
|
|
6
6
|
|
|
7
|
+

|
|
8
|
+
|
|
7
9
|
Named bit flags with symbolic access, set operations, and serialization
|
|
8
10
|
|
|
9
11
|
## Requirements
|
|
@@ -134,6 +136,20 @@ required.subset_of?(granted) # => true
|
|
|
134
136
|
granted.subset_of?(required) # => false
|
|
135
137
|
```
|
|
136
138
|
|
|
139
|
+
### Disjoint Check
|
|
140
|
+
|
|
141
|
+
Test whether two bit fields share zero flags in common. The empty bit field is
|
|
142
|
+
disjoint with every value (including itself).
|
|
143
|
+
|
|
144
|
+
```ruby
|
|
145
|
+
admin = Permissions.new(:admin)
|
|
146
|
+
viewer = Permissions.new(:read)
|
|
147
|
+
|
|
148
|
+
admin.disjoint?(viewer) # => true (no overlap)
|
|
149
|
+
viewer.disjoint?(viewer) # => false (read overlaps with itself)
|
|
150
|
+
Permissions.new.disjoint?(admin) # => true (empty vs anything)
|
|
151
|
+
```
|
|
152
|
+
|
|
137
153
|
### Strict Mode
|
|
138
154
|
|
|
139
155
|
```ruby
|
|
@@ -209,6 +225,7 @@ Permissions.from_i(0b101).to_binary_string # => "101"
|
|
|
209
225
|
| `#added_flags(other)` | Return flags set in self but not in other |
|
|
210
226
|
| `#removed_flags(other)` | Return flags set in other but not in self |
|
|
211
227
|
| `#subset_of?(other)` | True if every flag set in self is also set in other |
|
|
228
|
+
| `#disjoint?(other)` | True when self and other share no flags in common |
|
|
212
229
|
| `#to_i` | Return the integer representation |
|
|
213
230
|
| `#to_binary_string(width: nil)` | Return the field as a `"0"`/`"1"` string, MSB-first |
|
|
214
231
|
| `#to_a` | Return an array of set flag names |
|
|
@@ -422,6 +422,20 @@ module Philiprehberger
|
|
|
422
422
|
other.to_i.allbits?(to_i)
|
|
423
423
|
end
|
|
424
424
|
|
|
425
|
+
# Check whether self and `other` share no flags in common.
|
|
426
|
+
#
|
|
427
|
+
# Returns true when the bitwise AND of the two underlying values is zero.
|
|
428
|
+
# The empty bit field is disjoint with every bit field, including itself.
|
|
429
|
+
#
|
|
430
|
+
# @param other [Base] another instance of the same BitField subclass
|
|
431
|
+
# @return [Boolean]
|
|
432
|
+
# @raise [Error] when `other` is not the same BitField subclass
|
|
433
|
+
def disjoint?(other)
|
|
434
|
+
raise Error, 'cannot compare different bit field types' unless other.is_a?(self.class)
|
|
435
|
+
|
|
436
|
+
@value.nobits?(other.to_i)
|
|
437
|
+
end
|
|
438
|
+
|
|
425
439
|
alias eql? ==
|
|
426
440
|
|
|
427
441
|
private
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-bit_field
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Named bit flags with a DSL for defining flags at bit positions, symbolic
|
|
14
14
|
read/set/clear/toggle, flag groups, bulk operations, bitwise OR/AND/XOR, JSON/hash
|