Class: Net::NTLM::FieldSet

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



453
454
455
# File 'lib/watobo/external/ntlm/ntlm.rb', line 453

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

Class Method Details

.define(&block) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
# File 'lib/watobo/external/ntlm/ntlm.rb', line 385

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



401
402
403
# File 'lib/watobo/external/ntlm/ntlm.rb', line 401

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

.int32LE(name, opts) ⇒ Object



405
406
407
# File 'lib/watobo/external/ntlm/ntlm.rb', line 405

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

.int64LE(name, opts) ⇒ Object



409
410
411
# File 'lib/watobo/external/ntlm/ntlm.rb', line 409

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

.namesObject



421
422
423
# File 'lib/watobo/external/ntlm/ntlm.rb', line 421

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

.optsObject



429
430
431
# File 'lib/watobo/external/ntlm/ntlm.rb', line 429

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

.prototypesObject



417
418
419
# File 'lib/watobo/external/ntlm/ntlm.rb', line 417

def prototypes
  @proto
end

.security_buffer(name, opts) ⇒ Object



413
414
415
# File 'lib/watobo/external/ntlm/ntlm.rb', line 413

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

.string(name, opts) ⇒ Object



397
398
399
# File 'lib/watobo/external/ntlm/ntlm.rb', line 397

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

.typesObject



425
426
427
# File 'lib/watobo/external/ntlm/ntlm.rb', line 425

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

Instance Method Details

#[](name) ⇒ Object

Raises:

  • (ArgumentError)


469
470
471
472
473
# File 'lib/watobo/external/ntlm/ntlm.rb', line 469

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)


475
476
477
478
479
# File 'lib/watobo/external/ntlm/ntlm.rb', line 475

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



485
486
487
# File 'lib/watobo/external/ntlm/ntlm.rb', line 485

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

#enable(name) ⇒ Object



481
482
483
# File 'lib/watobo/external/ntlm/ntlm.rb', line 481

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

#parse(str, offset = 0) ⇒ Object



461
462
463
# File 'lib/watobo/external/ntlm/ntlm.rb', line 461

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

#serializeObject



457
458
459
# File 'lib/watobo/external/ntlm/ntlm.rb', line 457

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

#sizeObject



465
466
467
# File 'lib/watobo/external/ntlm/ntlm.rb', line 465

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