Class: Net::NTLM::String

Inherits:
Field
  • Object
show all
Defined in:
lib/net/ntlm.rb,
lib/net/ntlm_http.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.



269
270
271
272
# File 'lib/net/ntlm.rb', line 269

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

Instance Method Details

#parse(str, offset = 0) ⇒ Object



274
275
276
277
278
279
280
281
# File 'lib/net/ntlm.rb', line 274

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

#serializeObject



283
284
285
286
287
288
289
# File 'lib/net/ntlm.rb', line 283

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

#value=(val) ⇒ Object



291
292
293
294
295
# File 'lib/net/ntlm.rb', line 291

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