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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f16348291b79d06cfaca4dd476c9035c08fb1d5fda2d533cd77640d510b3b1c
4
- data.tar.gz: 813565b60c755c8acbc193771f9094863de462f20db0c53b692ae6a0b717619c
3
+ metadata.gz: 9177b0d13311c9ded1be36cd0b56b4d62c9fbad315c823f19437c9a8886a66c6
4
+ data.tar.gz: 2e2ed3c15bd4f7fa8e3426dd577e115d75825bc3dbbed2e624515ac0cc5bcc06
5
5
  SHA512:
6
- metadata.gz: f34ce9c2b7e5c8e7d251669c68a0722131ec975289060503558427017fa9d680040aa3814fc0fd1fc9679a7551949b62722e9f2b96fa2128a7d1ce525c93ff2d
7
- data.tar.gz: a6282f0def79db8cf56a17c986ea4f7ff122e827f96c3ece8263b2e6368a92fd52c13f4b153985e3b520186ce8831dfbebb4e7daba6b17f295a29337d8736d9d
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
  [![Gem Version](https://badge.fury.io/rb/philiprehberger-bit_field.svg)](https://rubygems.org/gems/philiprehberger-bit_field)
5
5
  [![Last updated](https://img.shields.io/github/last-commit/philiprehberger/rb-bit-field)](https://github.com/philiprehberger/rb-bit-field/commits/main)
6
6
 
7
+ ![philiprehberger-bit_field](https://raw.githubusercontent.com/philiprehberger/rb-bit-field/main/package-card.webp)
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 |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module BitField
5
- VERSION = '0.7.0'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
@@ -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.7.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-03 00:00:00.000000000 Z
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