Class: Net::BER::BerIdentifiedOid

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oid) ⇒ BerIdentifiedOid

Returns a new instance of BerIdentifiedOid.



62
63
64
65
66
67
# File 'lib/net/ber.rb', line 62

def initialize oid
  if oid.is_a?(String)
    oid = oid.split(/\./).map {|s| s.to_i }
  end
  @value = oid
end

Instance Attribute Details

#ber_identifierObject

Returns the value of attribute ber_identifier.



60
61
62
# File 'lib/net/ber.rb', line 60

def ber_identifier
  @ber_identifier
end

Instance Method Details

#to_berObject

Raises:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/net/ber.rb', line 69

def to_ber
  # Provisional implementation.
  # We ASSUME that our incoming value is an array, and we
  # use the Array#to_ber_oid method defined below.
  # We probably should obsolete that method, actually, in
  # and move the code here.
  # WE ARE NOT CURRENTLY ENCODING THE BER-IDENTIFIER.
  # This implementation currently hardcodes 6, the universal OID tag.
  ary = @value.dup
  first = ary.shift
  raise Net::BER::BerError.new(" invalid OID" ) unless [0,1,2].include?(first)
  first = first * 40 + ary.shift
  ary.unshift first
  oid = ary.pack("w*")
  [6, oid.length].pack("CC") + oid
end