Class: OSPFv2::OspfVersion
Instance Method Summary collapse
- #encode ⇒ Object (also: #enc)
-
#initialize(version = 2) ⇒ OspfVersion
constructor
A new instance of OspfVersion.
- #to_hash ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
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
#encode ⇒ Object Also known as: enc
51 52 53 |
# File 'lib/ie/ospf_version.rb', line 51 def encode [@ospf_version].pack('C') end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/ie/ospf_version.rb', line 33 def to_hash to_i end |
#to_i ⇒ Object
36 37 38 |
# File 'lib/ie/ospf_version.rb', line 36 def to_i @ospf_version end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/ie/ospf_version.rb', line 39 def to_s self.class.to_s.split('::').last + ": #{to_sym}" end |
#to_sym ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/ie/ospf_version.rb', line 42 def to_sym case @ospf_version when 2 ; :v2 when 3 ; :v3 else ':v?' end end |