Class: OSPFv2::AuType

Inherits:
Object show all
Defined in:
lib/ie/au_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(au_type = 0) ⇒ AuType

Returns a new instance of AuType.



27
28
29
30
31
32
33
34
35
36
# File 'lib/ie/au_type.rb', line 27

def initialize(au_type=0)
  @au_type=0
  case au_type
  when :null, 0            ; @au_type = 0
  when :simple_password, 1 ; @au_type = 1
  when :cryptographic, 2   ; @au_type = 2
  else
    @au_type = au_type if au_type.is_a?(Integer)
  end
end

Instance Method Details

#encodeObject Also known as: enc



60
61
62
# File 'lib/ie/au_type.rb', line 60

def encode
  [@au_type].pack('n')
end

#to_hashObject



38
39
40
# File 'lib/ie/au_type.rb', line 38

def to_hash
  to_sym
end

#to_iObject



42
43
44
# File 'lib/ie/au_type.rb', line 42

def to_i
  @au_type
end

#to_sObject



46
47
48
# File 'lib/ie/au_type.rb', line 46

def to_s
  self.class.to_s.split('::').last + ": #{au_to_s}"
end

#to_symObject



50
51
52
53
54
55
56
57
58
# File 'lib/ie/au_type.rb', line 50

def to_sym
  case @au_type
  when 2  ; :cryptographic
  when 1  ; :simple_password
  when 0  ; :null
  else
    :undefined?
  end
end