Class: Net::NTLM::FieldSet
- Inherits:
-
Object
- Object
- Net::NTLM::FieldSet
- Defined in:
- lib/net/ntlm.rb,
lib/net/ntlm_http.rb
Overview
base class of data structure
Direct Known Subclasses
Class Method Summary collapse
- .define(&block) ⇒ Object
- .int16LE(name, opts) ⇒ Object
- .int32LE(name, opts) ⇒ Object
- .int64LE(name, opts) ⇒ Object
- .names ⇒ Object
- .opts ⇒ Object
- .prototypes ⇒ Object
- .security_buffer(name, opts) ⇒ Object
- .string(name, opts) ⇒ Object
- .types ⇒ Object
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
- #disable(name) ⇒ Object
- #enable(name) ⇒ Object
-
#initialize ⇒ FieldSet
constructor
A new instance of FieldSet.
- #parse(str, offset = 0) ⇒ Object
- #serialize ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ FieldSet
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 |
.names ⇒ Object
398 399 400 |
# File 'lib/net/ntlm.rb', line 398 def names @proto.map{|n, t, o| n} end |
.opts ⇒ Object
406 407 408 |
# File 'lib/net/ntlm.rb', line 406 def opts @proto.map{|n, t, o| o} end |
.prototypes ⇒ Object
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 |
.types ⇒ Object
402 403 404 |
# File 'lib/net/ntlm.rb', line 402 def types @proto.map{|n, t, o| t} end |
Instance Method Details
#[](name) ⇒ Object
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
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 |
#serialize ⇒ Object
434 435 436 |
# File 'lib/net/ntlm.rb', line 434 def serialize @alist.map{|n, f| f.serialize }.join end |
#size ⇒ Object
442 443 444 |
# File 'lib/net/ntlm.rb', line 442 def size @alist.inject(0){|sum, a| sum += a[1].size} end |