Class: Net::NTLM::String

Inherits:
Field
  • Object
show all
Defined in:
lib/watobo/external/ntlm/ntlm.rb

Instance Attribute Summary

Attributes inherited from Field

#active, #value

Instance Method Summary collapse

Methods inherited from Field

#size

Constructor Details

#initialize(opts) ⇒ String

Returns a new instance of String.


292
293
294
295
# File 'lib/watobo/external/ntlm/ntlm.rb', line 292

def initialize(opts)
  super(opts)
  @size = opts[:size]
end

Instance Method Details

#parse(str, offset = 0) ⇒ Object


297
298
299
300
301
302
303
304
# File 'lib/watobo/external/ntlm/ntlm.rb', line 297

def parse(str, offset=0)
  if @active and str.size >= offset + @size
    @value = str[offset, @size]
    @size
  else
    0
  end
end

#serializeObject


306
307
308
309
310
311
312
# File 'lib/watobo/external/ntlm/ntlm.rb', line 306

def serialize
  if @active
    @value
  else
    ""
  end
end

#value=(val) ⇒ Object


314
315
316
317
318
# File 'lib/watobo/external/ntlm/ntlm.rb', line 314

def value=(val)
  @value = val
  @size = @value.nil? ? 0 : @value.size
  @active = (@size > 0)
end