Class: RetroIDL::ASN::DefinedValue

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

Overview

X.680 section 17.3

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ DefinedValue

Returns a new instance of DefinedValue.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/retro_idl/asn/defined_value.rb', line 24

def initialize(**opts)

    @location = opts[:location]
    @mod = nil

    if RetroIDL::ASN.is_identifier?(@location, **opts[:ref])                
        @symbol = opts[:ref].to_s
    else
        raise ASNError
    end
    
end

Instance Method Details

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



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
# File 'lib/retro_idl/asn/defined_value.rb', line 38

def link(mod, stack)

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

        @mod = nil

        if mod.symbol(@symbol)

            if mod.symbol(@symbol).link(mod, [])

                super(mod, stack)

            end
            
        else

            ASN.putError(@location, "DefinedValue governing type is not defined")

        end

    end

    @mod

end

#to_sString

Convert object to ASN.1 syntax representation

Returns:

  • (String)

    ASN.1 syntax representation

Raises:



76
77
78
79
80
# File 'lib/retro_idl/asn/defined_value.rb', line 76

def to_s

    "#{@symbol}"
    
end

#valueArray, ...

return the Ruby native representation of this DefinedType

Returns:

  • (Array, Hash, Numeric, String)

    native value

Raises:

  • (ASNError)

    value cannot be returned if object is not linked



69
70
71
72
73
# File 'lib/retro_idl/asn/defined_value.rb', line 69

def value

    @mod.symbol(@symbol).value

end