• Stars
    star
    26
  • Rank 930,752 (Top 19 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bit Fields for Crystal Language

Bit Fields for Crystal-Lang

Pure Crystal implementation of Bit Fields. Handles encoding/decoding of bytes.

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  bitfields:
    github: elorest/bitfields
  1. Run shards install

Usage

require "bitfields"

class CrossBit < BitFields
  bf rpms : UInt32, 32
  bf temp : UInt8, 4 
  bf psi : UInt16, 9 
  bf power : UInt8, 1 
  bf lights : UInt8, 2 
end

crossbit = CrossBit.new(Bytes[109, 121, 110, 97, 109, 245])
crossbit.temp          #=> 13_u8
crossbit.psi           #=> 342_u16
crossbit.power         #=> 1_u8
crossbit.lights        #=> 3_u8
crossbit.to_slice      #=> Bytes[109, 121, 110, 97, 109, 245]
crossbit.to_s          #=> |lights|power|psi|temp|rpms|
                       #=> |11|1|101010110|1101|01100001011011100111100101101101|
crossbit.power = 0     #=> 0_u8
crossbit.to_slice      #=> Bytes[109, 121, 110, 97, 109, 213]

Contributing

  1. Fork it (https://github.com/elorest/bitfields/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

More Repositories

1

petergate

Easy to use and read action and content based authorizations.
Ruby
195
star
2

cry

Ability to execute crystal code in a fashion similar to pry edit.
Crystal
34
star
3

CRelease

Application to simpify versioning and releasing crystal projects.
Crystal
17
star
4

vim-slang

Vim plugin for Slim-lang in Crystal
Vim Script
12
star
5

rails-competency-test

9
star
6

compiled_license

Compiles all Licenses from project into binary for MIT compliance
Crystal
9
star
7

detailed-vim

JavaScript
3
star
8

amber-crud

Example with Amber_Crystal
Crystal
3
star
9

git_deploy

git deploy for crystal web apps.
Crystal
3
star
10

can_example

Crystal
2
star
11

str_compressor

String Compressor for Crystal Lang
Crystal
2
star
12

acts_as_better_tree

An alternative to nested_sets and acts_as_tree. Designed to be a drop in replacement for acts_as_tree. Replaces betternestedset without the slow inserts when dealing with a large dataset. Used by upillar.com on a dataset of over 900,000 categories with no slow downs. In tests it shows a 285% speed increase on inserts with a dataset of 100k categories. As datasets become larger its insert speed stays about the same when nested_sets become slower. In all of my tests read speeds have been comparable with nested sets on everything but all_children which takes is inperceptibly slower on a dataset of 100k than betternestedset.
Ruby
2
star
13

dp_blog_presentation

Ruby
1
star
14

homebrew-crystal

Installation for crelease
Ruby
1
star
15

photocation

Ruby
1
star
16

image_encrypter

Helping humans visualize encryption strength!
Crystal
1
star
17

hex_encode

Simple shard that encodes binary to hex.
Crystal
1
star
18

dotfiles

Making dotfiles great again.
Vim Script
1
star
19

easy_timer

A simple and elegant way to add timer functionality to your projects. Adds class method :timer and instance method :verbose to Time class.
Ruby
1
star
20

skaf

Scaffolding for Kemal
Crystal
1
star