Class BinaryBlocker::PackedNumberEncoder
In: lib/blocker.rb
Parent: SimpleEncoder
GroupEncoder ListOfEncoder Blocker FixedArrayEncoder CountedArrayEncoder Encoder SimpleEncoder BitFieldEncoder OneOfEncoder PackedNumberEncoder PackedDateEncoder PackedDateTimeEncoder FixedStringEncoder FixedUTF16StringEncoder BinaryBlocker Module: BinaryBlocker

Methods

Public Class methods

[Source]

     # File lib/blocker.rb, line 426
426:     def initialize(*opts)
427:       initialize_options(*opts)
428:       
429:       @length = @opts[:length].to_i
430:       raise ArgumentError.new("Missing or invalid string length") unless @length > 0
431:       @length += 1 if @length[0] == 1
432:       @bytes = @length / 2
433:       @format = "H#{@length}"
434:       
435:       @key = @opts[:key]
436:       @valid = @opts[:valid]
437:       
438:       initialize_data(*opts)
439:     end

Public Instance methods

[Source]

     # File lib/blocker.rb, line 441
441:     def internal_block(val)
442:       ["%0#{@length}d" % val].pack(@format)
443:     end

[Source]

     # File lib/blocker.rb, line 445
445:     def internal_deblock(io)
446:       buffer = io.read(@bytes)
447:       result = buffer.unpack(@format)
448:       result.first.to_i
449:     end

[Validate]