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.



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

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