Class: Fixnum

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

Instance Method Summary collapse

Instance Method Details

#to_berObject

to_ber



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

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.



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

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

#to_ber_enumeratedObject

to_ber_enumerated



411
412
413
# File 'lib/net/ber.rb', line 411

def to_ber_enumerated
  "\012" + to_ber_internal
end

#to_ber_length_encodingObject

to_ber_length_encoding



418
419
420
421
422
423
424
425
# File 'lib/net/ber.rb', line 418

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