Class: OSPFv2::TrafficEngineeringMetric_Tlv

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

Instance Attribute 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 = {}) ⇒ TrafficEngineeringMetric_Tlv

Returns a new instance of TrafficEngineeringMetric_Tlv.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 21

def initialize(arg={})
  @tlv_type,  = 5
  @te_metric = 0

  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

#te_metricObject (readonly)

Returns the value of attribute te_metric.



19
20
21
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 19

def te_metric
  @te_metric
end

#tlv_typeObject (readonly)

Returns the value of attribute tlv_type.



19
20
21
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 19

def tlv_type
  @tlv_type
end

Instance Method Details

#__parse(s) ⇒ Object



38
39
40
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 38

def __parse(s)
  @tlv_type, _, @te_metric = s.unpack('nnN')
end

#encodeObject



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

def encode
  [@tlv_type, 4, @te_metric].pack('nnN')
end

#to_sObject



43
44
45
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 43

def to_s
  "Admin Metric : #{te_metric}"
end

#to_s_junos_style(ident = 0) ⇒ Object



47
48
49
# File 'lib/lsa/tlv/traffic_engineering_metric.rb', line 47

def to_s_junos_style(ident=0)
  "  "*ident + "RtrAddr (1), length #{@length}: #{router_id.to_ip}"
end