Class: Net::NTLM::FieldSet

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ntlm.rb

Overview

base class of data structure

Direct Known Subclasses

Message

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFieldSet

Returns a new instance of FieldSet.



430
431
432
# File 'lib/net/ntlm.rb', line 430

def initialize
  @alist = self.class.prototypes.map{ |n, t, o| [n, t.new(o)] }
end

Class Method Details

.define(&block) ⇒ Object



362
363
364
365
366
367
368
369
370
371
372
# File 'lib/net/ntlm.rb', line 362

def define(&block)
  c = Class.new(self)
  def c.inherited(subclass)
    proto = @proto
    subclass.instance_eval {
      @proto = proto
    }
  end
  c.module_eval(&block)
  c
end

.int16LE(name, opts) ⇒ Object



378
379
380
# File 'lib/net/ntlm.rb', line 378

def int16LE(name, opts)
  add_field(name, Int16LE, opts)
end

.int32LE(name, opts) ⇒ Object



382
383
384
# File 'lib/net/ntlm.rb', line 382

def int32LE(name, opts)
  add_field(name, Int32LE, opts)
end

.int64LE(name, opts) ⇒ Object



386
387
388
# File 'lib/net/ntlm.rb', line 386

def int64LE(name, opts)
  add_field(name, Int64LE, opts)
end

.namesObject



398
399
400
# File 'lib/net/ntlm.rb', line 398

def names
  @proto.map{|n, t, o| n}
end

.optsObject



406
407
408
# File 'lib/net/ntlm.rb', line 406

def opts
  @proto.map{|n, t, o| o}
end

.prototypesObject



394
395
396
# File 'lib/net/ntlm.rb', line 394

def prototypes
  @proto
end

.security_buffer(name, opts) ⇒ Object



390
391
392
# File 'lib/net/ntlm.rb', line 390

def security_buffer(name, opts)
  add_field(name, SecurityBuffer, opts)
end

.string(name, opts) ⇒ Object



374
375
376
# File 'lib/net/ntlm.rb', line 374

def string(name, opts)
  add_field(name, String, opts)
end

.typesObject



402
403
404
# File 'lib/net/ntlm.rb', line 402

def types
  @proto.map{|n, t, o| t}
end

Instance Method Details

#[](name) ⇒ Object

Raises:

  • (ArgumentError)


446
447
448
449
450
# File 'lib/net/ntlm.rb', line 446

def [](name)
  a = @alist.assoc(name.to_s.intern)
  raise ArgumentError, "no such field: #{name}" unless a
  a[1]
end

#[]=(name, val) ⇒ Object

Raises:

  • (ArgumentError)


452
453
454
455
456
# File 'lib/net/ntlm.rb', line 452

def []=(name, val)
  a = @alist.assoc(name.to_s.intern)
  raise ArgumentError, "no such field: #{name}" unless a
  a[1] = val
end

#disable(name) ⇒ Object



462
463
464
# File 'lib/net/ntlm.rb', line 462

def disable(name)
  self[name].active = false
end

#enable(name) ⇒ Object



458
459
460
# File 'lib/net/ntlm.rb', line 458

def enable(name)
  self[name].active = true
end

#parse(str, offset = 0) ⇒ Object



438
439
440
# File 'lib/net/ntlm.rb', line 438

def parse(str, offset=0)
  @alist.inject(offset){|cur, a|  cur += a[1].parse(str, cur)}
end

#serializeObject



434
435
436
# File 'lib/net/ntlm.rb', line 434

def serialize
  @alist.map{|n, f| f.serialize }.join
end

#sizeObject



442
443
444
# File 'lib/net/ntlm.rb', line 442

def size
  @alist.inject(0){|sum, a| sum += a[1].size}
end