class PacketGen::Header::OSPFv3::ArrayOfLSA
This class defines a specialized {Types::Array array} to handle series of {LSA LSAs} or {LSAHeader LSAHeaders}. It recognizes known LSA
types and infers correct type. @author Sylvain Daubert
Public Class Methods
new(options={})
click to toggle source
@param [Hash] options @option options [Types::Int] counter Int object used as a counter for this set @option options [Boolean] only_headers if true
, only {LSAHeader LSAHeaders}
will be added to this array.
Calls superclass method
# File lib/packetgen/header/ospfv3/lsa.rb, line 194 def initialize(options={}) super @only_headers = options[:only_headers] || false end
Private Instance Methods
get_lsa_class_by_human_type(htype)
click to toggle source
# File lib/packetgen/header/ospfv3/lsa.rb, line 219 def get_lsa_class_by_human_type(htype) klassname = "LSA#{htype.to_s.delete('-')}" begin if OSPFv3.const_defined? klassname OSPFv3.const_get klassname else LSA end rescue NameError LSA end end
real_type(lsah)
click to toggle source
# File lib/packetgen/header/ospfv3/lsa.rb, line 232 def real_type(lsah) @only_headers ? lsah.class : get_lsa_class_by_human_type(lsah.human_type) end
record_from_hash(hsh)
click to toggle source
# File lib/packetgen/header/ospfv3/lsa.rb, line 201 def record_from_hash(hsh) raise ArgumentError, 'hash should have :type key' unless hsh.key? :type klass = if @only_headers LSAHeader else case hsh[:type] when String get_lsa_class_by_human_type(hsh[:type]) when Integer get_lsa_class_by_human_type(LSAHeader::TYPES.key(hsh[:type])) else LSA end end klass.new(hsh) end