Class: Fixnum

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

Instance Method Summary collapse

Instance Method Details

#to_berObject

to_ber



408
409
410
# File 'lib/net/ber.rb', line 408

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.



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

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

#to_ber_enumeratedObject

to_ber_enumerated



415
416
417
# File 'lib/net/ber.rb', line 415

def to_ber_enumerated
  "\012" + to_ber_internal
end

#to_ber_length_encodingObject

to_ber_length_encoding



422
423
424
425
426
427
428
429
# File 'lib/net/ber.rb', line 422

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