bits_in_bytes 0.1.1 → 0.1.2

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: 863ddb8fc11c3726a64d316a850d81f10332a90b018f13fbb2f63576646808d6
4
- data.tar.gz: 62805a853fdda87177f9d5c69e35f50e2e416f7487c976ff9a52c2b1e1b3ec36
3
+ metadata.gz: 5fee2b65cecbf81a180d8f488084ecdb318156728af08484136c2b89c87b6fd0
4
+ data.tar.gz: abbe2d5b610f681e55d165cd282009ca301feee9a018eb7ebe3403af354a9d2c
5
5
  SHA512:
6
- metadata.gz: 12e3bec780442ec4b185e37c6ef16c6a6587f261d38e2115d81a5a8446633b70a34179286dbaf0bf4970e6fc7446a1902abc58096cd4ad4b8f734e17bf952069
7
- data.tar.gz: f227b7160c97dd74603d800ab778570da140d1689de3d7508fdc27c6f293db810560cafd66ca7bb7ffab691ca6bdf4afc4718b81c1a58eacee0d0e3a2644a805
6
+ metadata.gz: 5044c967008eb994ef694f80bc168e0186a69bce53c3d5b17cbcb6df15da114148bfd74709d286dbc9793ddb00c8af34bd1fb38690785e0d6b5e7db620ffc979
7
+ data.tar.gz: d944481948d8fa06ea6686469beb4c4bf9384f4988b384a06a047e614c57caabcbd73ffc8806a7ca76441c560b0df31e17182690db25ff4b526122c9e1d7ede4
data/README.md CHANGED
@@ -22,16 +22,20 @@ Or install it yourself as:
22
22
  ## Usage
23
23
 
24
24
  You can use the 'BitInByte' object to find out which bits are set in a given
25
- byte. The first argument is the position of the bit you would like to check,
26
- starting with the index value one. The second argument is the decimal byte value, which must not
27
- be bigger than 255.
25
+ byte. The first argument is the position of the bit you would like to check.
26
+ The position must be in the range of 1 to 8.
27
+ The second argument is the actual byte value, which must be in the
28
+ range of 0 to 255. It may be a decimal, hex, octal or binary value.
28
29
 
29
30
  Simple examples:
30
31
  ```ruby
31
- puts BitInByte.new(8, 128).value # output -> true
32
- puts BitInByte.new(4, 8).value # output -> false
33
- puts BitInByte.new(1, 17).value # output -> true
34
- puts BitInByte.new(3, 64).value # output -> false
32
+ BitInByte.new(8, 128).value # output -> true
33
+ BitInByte.new(4, 8).value # output -> false
34
+ BitInByte.new(1, 17).value # output -> true
35
+ BitInByte.new(3, 64).value # output -> false
36
+ BitInByte.new(5, 0x10).value # output -> true
37
+ BitInByte.new(7, 0b00000011).value # output -> false
38
+ BitInByte.new(2, 0o12).value # output -> true
35
39
  ```
36
40
 
37
41
  ## Development
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["thexsalkin@gmail.com"]
11
11
 
12
12
  spec.summary = "Gem to determine which bits are set in a byte"
13
- spec.description = "Gem which allows the user to determine which bits are set in a decimal byte value"
13
+ spec.description = "Gem which allows the user to determine which bits are set inside a byte value"
14
14
  spec.homepage = "https://github.com/SNException/bits_in_bytes"
15
15
  spec.license = "MIT"
16
16
 
@@ -19,6 +19,15 @@
19
19
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
+
23
+ # The BitInByte object represents a single bit inside a byte value.
24
+ # He accepts a postion of himself which must be in the range
25
+ # of 1-8 and the actualbyte value which must be in the range of 0-255.
26
+ # The byte value may be decimal, hex, octal, or binary.
27
+ #
28
+ # author:: Niklas Schultz
29
+ # version:: 0.1.2
30
+ # license:: MIT
22
31
  class BitInByte
23
32
  def initialize(pos, byte)
24
33
  @pos = pos
@@ -26,8 +35,8 @@ class BitInByte
26
35
  end
27
36
 
28
37
  def value
29
- raise ArgumentError, 'pos must 1-8' if @pos <= 0 || @pos > 8
30
- raise ArgumentError, 'byte must 0-255' if @byte < 0 || @byte > 255
38
+ raise ArgumentError, 'pos must be 1-8' if @pos <= 0 || @pos > 8
39
+ raise ArgumentError, 'byte must be 0-255' if @byte < 0 || @byte > 255
31
40
 
32
41
  position = @pos - 1
33
42
  ((1 << position) & @byte) != 0
data/lib/core/version.rb CHANGED
@@ -20,5 +20,5 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
  module BitsInBytes
23
- VERSION = "0.1.1"
23
+ VERSION = '0.1.2'
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bits_in_bytes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklas Schultz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-10 00:00:00.000000000 Z
11
+ date: 2019-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,8 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
- description: Gem which allows the user to determine which bits are set in a decimal
56
- byte value
55
+ description: Gem which allows the user to determine which bits are set inside a byte
56
+ value
57
57
  email:
58
58
  - thexsalkin@gmail.com
59
59
  executables: []