Class: Fixnum

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

Instance Method Summary collapse

Instance Method Details

#to_berObject

to_ber



397
398
399
# File 'lib/net/ber.rb', line 397

def to_ber
  "\002" + to_ber_internal
end

#to_ber_application(tag) ⇒ Object

Generate a BER-encoding for an application-defined INTEGER. Example: SNMP’s Counter, Gauge, and TimeTick types.



423
424
425
# File 'lib/net/ber.rb', line 423

def to_ber_application tag
    [0x40 + tag].pack("C") + to_ber_internal
end

#to_ber_enumeratedObject

to_ber_enumerated



404
405
406
# File 'lib/net/ber.rb', line 404

def to_ber_enumerated
  "\012" + to_ber_internal
end

#to_ber_length_encodingObject

to_ber_length_encoding



411
412
413
414
415
416
417
418
# File 'lib/net/ber.rb', line 411

def to_ber_length_encoding
  if self <= 127
    [self].pack('C')
  else
    i = [self].pack('N').sub(/^[\0]+/,"")
    [0x80 + i.length].pack('C') + i
  end
end