Class: CiscoAclIntp::AceBase

Inherits:
AccessControlContainer show all
Includes:
Comparable
Defined in:
lib/cisco_acl_intp/ace_base.rb

Overview

AceBase: Base class of ACE(Access Control Entry). ACE is composed of each types of AceSpecs.

Direct Known Subclasses

ErrorAce, EvaluateAce, RemarkAce, StandardAce

Constant Summary collapse

NO_SEQ_NUMBER =

Number used when ACE does not has sequence number

-1

Constants inherited from AccessControlContainer

CiscoAclIntp::AccessControlContainer::TERM_COLOR_TABLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AccessControlContainer

#clean_acl_string, disable_color, #generate_tag_footer, #generate_tag_header, #generate_tagged_str, #method_missing, #to_s

Constructor Details

#initialize(opts) ⇒ AceBase

Constructor

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :number (Integer)

    Sequence number



21
22
23
# File 'lib/cisco_acl_intp/ace_base.rb', line 21

def initialize(opts)
  @seq_number = opts[:number] || NO_SEQ_NUMBER
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CiscoAclIntp::AccessControlContainer

Instance Attribute Details

#seq_numberInteger

Parameters:

  • value (Integer)

    ACL sequence number

Returns:

  • (Integer)


12
13
14
# File 'lib/cisco_acl_intp/ace_base.rb', line 12

def seq_number
  @seq_number
end

Instance Method Details

#<=>(other) ⇒ Integer

Note:

Using “Comparable” module, ‘==’ operator is defined by ‘<=>’ operator. But ACE object will be compared by its value (comparison by the equivalence), instead of sequence number. The ‘==’ operator will be overriden in child class.

Compare by sequence number

Parameters:

Returns:

  • (Integer)

    Compare with protocol/port number



38
39
40
# File 'lib/cisco_acl_intp/ace_base.rb', line 38

def <=>(other)
  @seq_number <=> other.seq_number
end

#contains?Boolean

This method is abstract.

Search matched ACE

Returns:

  • (Boolean)

    Matched or not



45
46
47
# File 'lib/cisco_acl_intp/ace_base.rb', line 45

def contains?
  false
end

#seq_number?Boolean

Check this object has sequence number

Returns:

  • (Boolean)


27
28
29
# File 'lib/cisco_acl_intp/ace_base.rb', line 27

def seq_number?
  @seq_number > NO_SEQ_NUMBER
end