Module: Net::BER

Defined in:
lib/net/ber.rb

Defined Under Namespace

Modules: BERParser Classes: BerError, BerIdentifiedArray, BerIdentifiedNull, BerIdentifiedOid, BerIdentifiedString

Class Method Summary collapse

Class Method Details

.compile_syntax(syn) ⇒ Object

– This condenses our nicely self-documenting ASN hashes down to an array for fast lookups. Scoped to be called as a module method, but not intended for user code to call.



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/net/ber.rb', line 93

def self.compile_syntax syn
  out = [nil] * 256
  syn.each do |tclass,tclasses|
    tagclass = {:universal=>0, :application=>64, :context_specific=>128, :private=>192} [tclass]
    tclasses.each do |codingtype,codings|
      encoding = {:primitive=>0, :constructed=>32} [codingtype]
      codings.each do |tag,objtype|
        out[tagclass + encoding + tag] = objtype
      end
    end
  end
  out
end

.ord(value) ⇒ Object



107
108
109
110
# File 'lib/net/ber.rb', line 107

def self.ord(value)
  value = value.ord if value.respond_to?(:ord)
  value
end