dmendel/bindata
소개
BinData - Ruby에서 바이너리 데이터 읽기 및 쓰기
보안 및 개인정보 보호측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalWhat is BinData?
Do you ever find yourself writing code like this?
io = File.open(...)
len = io.read(2).unpack("v")
name = io.read(len)
width, height = io.read(8).unpack("VV")
puts "Rectangle #{name} is #{width} x #{height}"
It’s ugly, violates DRY and doesn't feel like Ruby.
There is a better way. Here’s how you’d write the above using BinData.
class Rectangle < BinData::Record
endian :little
uint16 :len
string :name, :read_length => :len
uint32 :width
uint32 :height
end
io = File.open(...)
r = Rectangle.read(io)
puts "Rectangle #{r.name} is #{r.width} x #{r.height}"
BinData provides a declarative way to read and write structured binary data.
This means the programmer specifies what the format of the binary
data is, and BinData works out how to read and write data in this
format. It is an easier (and more readable) alternative to
Ruby's #pack and #unpack methods.
BinData makes it easy to create new data types. It supports all the common primitive datatypes that are found in structured binary data formats. Support for dependent and variable length fields is built in.
Installation
$ gem install bindata
Documentation
Contact
If you have any queries / bug reports / suggestions, please contact me (Dion Mendel) via email at [email protected]
관련 프로젝트 살펴보기
불러오는 중…