Class: OSPFv2::OspfVersion

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

Instance Method Summary collapse

Constructor Details

#initialize(version = 2) ⇒ OspfVersion

Returns a new instance of OspfVersion.



25
26
27
28
29
30
31
32
# File 'lib/ie/ospf_version.rb', line 25

def initialize(version=2)
  case version
  when :v2, 2 ; @ospf_version = 2
  when :v3, 3 ; @ospf_version = 3
  else
    @ospf_version = 0
  end
end

Instance Method Details

#encodeObject Also known as: enc



59
60
61
# File 'lib/ie/ospf_version.rb', line 59

def encode
  [@ospf_version].pack('C')
end

#to_hashObject



41
42
43
# File 'lib/ie/ospf_version.rb', line 41

def to_hash
  to_i
end

#to_iObject



44
45
46
# File 'lib/ie/ospf_version.rb', line 44

def to_i
  @ospf_version
end

#to_sObject



33
34
35
36
37
38
39
40
# File 'lib/ie/ospf_version.rb', line 33

def to_s
  case @ospf_version
  when 2  ; '2'
  when 3  ; '3'
  else
    'unknown'
  end
end

#to_symObject



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

def to_sym
  case @ospf_version
  when 2  ; :v2
  when 3  ; :v3
  else
    ':v?'
  end
end