Class: RetroIDL::ASN::ENUMERATED

Inherits:
BaseType
  • Object
show all
Defined in:
lib/retro_idl/asn/enumerated.rb

Overview

X.680 section 20

Constant Summary collapse

TAG_CLASS_NUMBER =
10
TAG_CLASS =
:universal

Instance Attribute Summary

Attributes inherited from BaseType

#id

Instance Method Summary collapse

Methods inherited from BaseType

===

Constructor Details

#initialize(**opts) ⇒ ENUMERATED

Returns a new instance of ENUMERATED.



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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/retro_idl/asn/enumerated.rb', line 26

def initialize(**opts)

    super(**opts)

    errors = false
    
    @exception = opts[:exception]
    @extensible = opts[:extensible]
    @additional = nil

    begin

    @root = ValueList.new(opts[:root], EnumerationItem)

    rescue ASNError

    errors = true
    
    end

    if opts[:additional]

        begin

        @additional = ValueList.new(opts[:additional], EnumerationItem)

        rescue ASNError

        errors = true

        end

        if @additional

            @additional.list.each do |id, item|

                if @root.list.keys.include? id

                    ASN.putError(item.location, "duplicate EnumerationItem")
                    errors = true

                end

            end

        end

    end

    if errors

        raise ASNError.new

    end
    
end

Instance Method Details

#evaluate(value) ⇒ Object



121
122
123
124
125
# File 'lib/retro_idl/asn/enumerated.rb', line 121

def evaluate(value)

    false

end

resolve symbols to definitions in module

Parameters:

  • mod (MODULE)

    module this type belongs to

  • stack (Array)

    objects called before this object for depth first search of recursion

Returns:

  • (MODULE)

    object has been linked

  • (nil)

    object has not been linked



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/retro_idl/asn/enumerated.rb', line 84

def link(mod, stack)

    if @mod.nil? or @mod != mod

        @mod = nil

        if @root.link(mod, stack)

            if @additional.nil? or @additional.link(mod, stack)
            
                super(mod, stack)

            end
            
        end

    end

    @mod
    
end

#to_sString

Convert object to ASN.1 syntax representation

Returns:

  • (String)

    ASN.1 syntax representation

Raises:



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/retro_idl/asn/enumerated.rb', line 107

def to_s

    result = "#{@tag} ENUMERATED { #{@root} "

    if @extensible

        result << ", ... "

    end

    result << "} #{@constraint}"

end