Class: Nl::DataTypes::Pad

Inherits:
Base
  • Object
show all
Defined in:
nl/lib/nl/datatypes.rb

Instance Method Summary collapse

Methods inherited from Base

#coerce, #nlattr_type_flags

Constructor Details

#initialize(length = nil) ⇒ Pad

Returns a new instance of Pad.



227
228
229
# File 'nl/lib/nl/datatypes.rb', line 227

def initialize(length = nil)
  @length = length
end

Instance Method Details

#decode(decoder, context: nil, nlattr_type_flags: 0) ⇒ Object



235
236
237
238
# File 'nl/lib/nl/datatypes.rb', line 235

def decode(decoder, context: nil, nlattr_type_flags: 0)
  @length ? decoder.skip(@length) : decoder.skip
  nil
end

#encode(encoder, _value, context: nil) ⇒ Object



231
232
233
# File 'nl/lib/nl/datatypes.rb', line 231

def encode(encoder, _value, context: nil)
  encoder.put_string(?\0.b * @length) if @length
end