Class: OSPFv2::OpaqueType
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from IE
#method_missing
Constructor Details
#initialize(opaque_type = 1) ⇒ OpaqueType
Returns a new instance of OpaqueType.
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/ie/opaque_type.rb', line 50
def initialize(opaque_type=1)
@opaque_type = case opaque_type
when Symbol
OpaqueType.to_i(opaque_type)
when Fixnum
opaque_type
else
raise ArgumentError, "Invalid OpaqueType #{opaque_type}"
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class OSPFv2::IE
Class Method Details
26
27
28
|
# File 'lib/ie/opaque_type.rb', line 26
def all
@opaque_type_sym_to_i.key
end
|
.to_i(arg) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/ie/opaque_type.rb', line 39
def to_i(arg)
return arg if arg.is_a?(Fixnum)
if @opaque_type_sym_to_i.has_key?(arg)
@opaque_type_sym_to_i[arg]
else
raise
end
end
|
.to_sym(arg) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/ie/opaque_type.rb', line 30
def to_sym(arg)
return arg unless arg.is_a?(Fixnum)
if @opaque_type_sym.has_key?(arg)
@opaque_type_sym[arg]
else
raise
end
end
|
Instance Method Details
#encode ⇒ Object
Also known as:
enc
71
72
73
|
# File 'lib/ie/opaque_type.rb', line 71
def encode
[@opaque_type].pack('C')
end
|
76
77
78
|
# File 'lib/ie/opaque_type.rb', line 76
def to_hash
to_sym
end
|
60
61
62
|
# File 'lib/ie/opaque_type.rb', line 60
def to_i
@opaque_type
end
|
63
64
65
|
# File 'lib/ie/opaque_type.rb', line 63
def to_s
self.class.to_s.split('::').last + ": #{to_sym}"
end
|
67
68
69
|
# File 'lib/ie/opaque_type.rb', line 67
def to_sym
OpaqueType.to_sym @opaque_type
end
|