Class: RetroIDL::ASN::EnumerationItem
- Inherits:
-
Object
- Object
- RetroIDL::ASN::EnumerationItem
- Defined in:
- lib/retro_idl/asn/enumeration_item.rb
Overview
An item within an ENUMERATED type
X.680 section 20
Instance Attribute Summary collapse
-
#location ⇒ Hash
readonly
Location record.
Instance Method Summary collapse
-
#initialize(**opts) ⇒ EnumerationItem
constructor
A new instance of EnumerationItem.
-
#link(mod, stack) ⇒ MODULE?
resolve symbols to definitions in module.
-
#to_s ⇒ String
Convert object to ASN.1 syntax representation.
Constructor Details
#initialize(**opts) ⇒ EnumerationItem
Returns a new instance of EnumerationItem.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/retro_idl/asn/enumeration_item.rb', line 26 def initialize(**opts) @id = opts[:id].to_s @location = opts[:location] @mod = nil @symbol = nil @number = nil if RetroIDL::ASN.is_identifier?(@location, @id) if opts[:number] if opts[:number].is_a? String @symbol = opts[:number].to_s else @number = opts[:number].to_i end end else raise ASNError end end |
Instance Attribute Details
#location ⇒ Hash (readonly)
Returns location record.
49 50 51 |
# File 'lib/retro_idl/asn/enumeration_item.rb', line 49 def location @location end |
Instance Method Details
#link(mod, stack) ⇒ MODULE?
resolve symbols to definitions in module
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/retro_idl/asn/enumeration_item.rb', line 52 def link(mod, stack) if @mod.nil? or @mod != mod @mod = nil if @symbol if mod.symbols(@symbol) @mod = mod else ASN.putError(@location, SYMBOL_UNDEFINED_ERROR) end else @mod = mod end end @mod end |
#to_s ⇒ String
Convert object to ASN.1 syntax representation
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/retro_idl/asn/enumeration_item.rb', line 83 def to_s if @symbol "#{@id} (#{@symbol})" elsif @number "#{@id} (#{@number})" else "#{@id}" end end |