Module: BIL
- Defined in:
- lib/bil.rb,
lib/bil/packer.rb,
lib/bil/version.rb,
lib/bil/unpacker.rb
Defined Under Namespace
Constant Summary collapse
- TABLE =
%w(z a b c d e f g h j k p q r t u Y A B C D E F G H J K P Q R T U).freeze
- VERSION =
'1.0.0'
Class Method Summary collapse
-
.pack(*array_of_ints) ⇒ String
Convenience method for packing an array of integers into a bil encoded string.
-
.unpack(string) ⇒ Array<Integer>
Convenience method for unpacking a bil encoded string into an array of integers.
Class Method Details
.pack(*array_of_ints) ⇒ String
Convenience method for packing an array of integers into a bil encoded string.
14 15 16 17 18 19 20 |
# File 'lib/bil.rb', line 14 def self.pack(*array_of_ints) ''.tap do |string| Packer.new do |chunk| string << chunk end.pack(*array_of_ints) end end |
.unpack(string) ⇒ Array<Integer>
Convenience method for unpacking a bil encoded string into an array of integers. Unknown characters will be ignored.
NB. This will only unpack the first bil encoded list within a string. For greater flexibility, look at Bil::Unpacker
30 31 32 33 34 35 36 |
# File 'lib/bil.rb', line 30 def self.unpack(string) [].tap do |array| Unpacker.new do |int| array << int end.unpack(StringIO.new(string)) end end |