Class: OSPFv2::LinkType_Tlv

Inherits:
Object show all
Includes:
Common, SubTlv
Defined in:
lib/lsa/tlv/link_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#ivar_to_klassname, #ivars, #set, #to_hash

Methods included from SubTlv

factory

Methods included from Tlv

factory

Constructor Details

#initialize(arg = {}) ⇒ LinkType_Tlv

Returns a new instance of LinkType_Tlv.



24
25
26
27
28
29
30
31
32
33
# File 'lib/lsa/tlv/link_type.rb', line 24

def initialize(arg={})
  @tlv_type, @link_type = 1,1
  if arg.is_a?(Hash) then
    set(arg.dup)
  elsif arg.is_a?(String)
    __parse(arg)
  else
    raise ArgumentError, "Invalid argument", caller
  end
end

Instance Attribute Details

Returns the value of attribute link_type.



23
24
25
# File 'lib/lsa/tlv/link_type.rb', line 23

def link_type
  @link_type
end

#tlv_typeObject (readonly)

Returns the value of attribute tlv_type.



23
24
25
# File 'lib/lsa/tlv/link_type.rb', line 23

def tlv_type
  @tlv_type
end

Class Method Details

.type_to_s(arg) ⇒ Object



17
18
19
# File 'lib/lsa/tlv/link_type.rb', line 17

def type_to_s(arg)
  "#{@link_type[arg]}"
end

Instance Method Details

#__parse(s) ⇒ Object



37
38
39
# File 'lib/lsa/tlv/link_type.rb', line 37

def __parse(s)
  @tlv_type, _, @link_type= s.unpack('nnC')
end

#encodeObject



34
35
36
# File 'lib/lsa/tlv/link_type.rb', line 34

def encode
  [@tlv_type, 1, @link_type,0,0,0].pack('nnCC3')
end

#to_sObject



40
41
42
# File 'lib/lsa/tlv/link_type.rb', line 40

def to_s
  "Link Type : #{LinkType_Tlv.type_to_s(link_type)}"
end