Class: RetroIDL::ASN::Tag
- Inherits:
-
Object
- Object
- RetroIDL::ASN::Tag
- Defined in:
- lib/retro_idl/asn/tag.rb
Overview
X.680 section 31.2
Instance Attribute Summary collapse
-
#encodingReference ⇒ String
readonly
EncodingReference.
-
#tagClass ⇒ :IMPLICIT, :EXPLICIT
readonly
Tag.
Instance Method Summary collapse
-
#initialize(**opts) ⇒ Tag
constructor
A new instance of Tag.
-
#link(mod, stack) ⇒ MODULE?
resolve symbols to definitions in module.
-
#tagClassNumber ⇒ Integer
Return the tag ClassNumber.
-
#to_s ⇒ String
Convert object to ASN.1 syntax representation.
Constructor Details
#initialize(**opts) ⇒ Tag
Returns a new instance of Tag.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/retro_idl/asn/tag.rb', line 23 def initialize(**opts) errors = false @mod = nil @tag = nil @symbol = nil @encodingReference = opts[:encodingReference] @tagClass = opts[:class] @location = opts[:location] @tagType = opts[:type] if opts[:classNumber][:ref] if RetroIDL::ASN.is_identifier?(@location, opts[:classNumber][:ref]) @symbol = opts[:classNumber][:ref] else errors = true end else @tagClassNumber = opts[:classNumber][:number] if @tagClassNumber < 0 ASN.putError(opts[:classNumber][:location], "ClassNumber must be an integer >= 0") errors = true end end if errors raise ASNError.new end end |
Instance Attribute Details
#encodingReference ⇒ String (readonly)
Returns EncodingReference.
70 71 72 |
# File 'lib/retro_idl/asn/tag.rb', line 70 def encodingReference @encodingReference end |
#tagClass ⇒ :IMPLICIT, :EXPLICIT (readonly)
Returns tag.
73 74 75 |
# File 'lib/retro_idl/asn/tag.rb', line 73 def tagClass @tagClass end |
Instance Method Details
#link(mod, stack) ⇒ MODULE?
resolve symbols to definitions in module
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/retro_idl/asn/tag.rb', line 104 def link(mod, stack) if @mod.nil? or @mod != mod @mod = nil if @symbol if mod.symbols(@symbol).nil? ASN.putError(@location, SYMBOL_UNDEFINED_ERROR) else @mod = mod.symbols(@symbol).link(mod, stack) end end else @mod end end |
#tagClassNumber ⇒ Integer
Return the tag ClassNumber
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/retro_idl/asn/tag.rb', line 81 def tagClassNumber if @mod if @symbol @symbol.value else @tagClassNumber end else raise ASNError.new LINK_ERROR end end |
#to_s ⇒ String
Convert object to ASN.1 syntax representation
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/retro_idl/asn/tag.rb', line 133 def to_s result = "[" if @encodingReference result << " #{@encodingReference} :" end if @tagClass result << " #{@tagClass}" end if @symbol result << " #{@symbol}" else result << " #{@tagClassNumber}" end result << " ] #{@tagType}" end |