Class BinaryBlocker::FixedUTF16StringEncoder
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 399
399:     def initialize(*opts)
400:       initialize_options(*opts)
401:       
402:       @length = @opts[:length].to_i
403:       @length *= 2
404:       raise ArgumentError.new("Missing or invalid string length") unless @length > 0
405:       @format = "Z#{@length}"
406:       
407:       @key = @opts[:key]
408:       @valid = @opts[:valid]
409:       
410:       initialize_data(*opts)
411:     end

Public Instance methods

[Source]

     # File lib/blocker.rb, line 413
413:     def internal_block(val)
414:       [Uconv.u8tou16(val || "")].pack(@format)
415:     end

[Source]

     # File lib/blocker.rb, line 417
417:     def internal_deblock(io)
418:       buffer = io.read(@length)
419:       Uconv.u16tou8(buffer).sub(/\000+$/,'')
420:     end

[Validate]