Class: Net::NTLM::String

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



5
6
7
8
# File 'lib/net/ntlm/string.rb', line 5

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

Instance Method Details

#parse(str, offset = 0) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/net/ntlm/string.rb', line 10

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

#serializeObject



19
20
21
22
23
24
25
# File 'lib/net/ntlm/string.rb', line 19

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

#value=(val) ⇒ Object



27
28
29
30
31
# File 'lib/net/ntlm/string.rb', line 27

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