Class: CiscoAclIntp::AcePortOperatorBase

Inherits:
AceSpecBase show all
Defined in:
lib/cisco_acl_intp/acespec_port_opr_base.rb

Overview

TCP/UDP Port Set Operator Class

Direct Known Subclasses

AcePortOpRange, AceUnaryOpBase

Constant Summary

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

Constructor Details

#initialize(begin_port, end_port = nil) ⇒ AcePortOperatorBase

Constructor

Parameters:

Raises:



24
25
26
27
28
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 24

def initialize(begin_port, end_port = nil)
  @operator = :any # default
  @begin_port = begin_port
  @end_port = end_port
end

Dynamic Method Handling

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

Instance Attribute Details

#begin_portAceProtoSpecBase (readonly) Also known as: port

Parameters:

Returns:



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

def begin_port
  @begin_port
end

#end_portAceProtoSpecBase (readonly)

Parameters:

Returns:



18
19
20
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 18

def end_port
  @end_port
end

#operatorObject (readonly)

Returns:



8
9
10
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 8

def operator
  @operator
end

Instance Method Details

#==(other) ⇒ Boolean

Check equality

Parameters:

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 33

def ==(other)
  @operator == other.operator &&
    @begin_port == other.begin_port &&
    @end_port == other.end_port
end

#check_any_operator(other) ⇒ Boolean (private)

ANY operator check

Parameters:

Returns:

  • (Boolean)


74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 74

def check_any_operator(other)
  case other
  when AcePortOpStrictAny
    # must match before AcePortOpAny (Base Class)
    contains_strict_any?(other)
  when AcePortOpAny
    contains_any?(other)
  else
    false # unknown operator
  end
end

#contains?(other) ⇒ Boolean

Specified port-set is contained or not?

Parameters:

  • other (AcePortOperator)

    Another operator

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 52

def contains?(other)
  case other
  when AcePortOpEq
    contains_eq?(other)
  when AcePortOpNeq
    contains_neq?(other)
  when AcePortOpLt
    contains_lt?(other)
  when AcePortOpGt
    contains_gt?(other)
  when AcePortOpRange
    contains_range?(other)
  else
    check_any_operator(other)
  end
end

#contains_any?(_other) ⇒ Boolean (private)

Operate ANY containing check

Parameters:

Returns:

  • (Boolean)


89
90
91
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 89

def contains_any?(_other)
  false
end

#contains_eq?(_other) ⇒ Boolean (private)

Operate EQUAL containing check

Parameters:

Returns:

  • (Boolean)


103
104
105
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 103

def contains_eq?(_other)
  false
end

#contains_gt?(_other) ⇒ Boolean (private)

Operate GREATER_THAN containing check

Parameters:

Returns:

  • (Boolean)


124
125
126
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 124

def contains_gt?(_other)
  false
end

#contains_lt?(_other) ⇒ Boolean (private)

Operate LOWER_THAN containing check

Parameters:

Returns:

  • (Boolean)


117
118
119
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 117

def contains_lt?(_other)
  false
end

#contains_neq?(_other) ⇒ Boolean (private)

Operate NOT_EQUAL containing check

Parameters:

Returns:

  • (Boolean)


110
111
112
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 110

def contains_neq?(_other)
  false
end

#contains_range?(_other) ⇒ Boolean (private)

Operate RANGE containing check

Parameters:

Returns:

  • (Boolean)


131
132
133
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 131

def contains_range?(_other)
  false
end

#contains_strict_any?(_other) ⇒ Boolean (private)

Operate STRICT_ANY containing check

Parameters:

Returns:

  • (Boolean)


96
97
98
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 96

def contains_strict_any?(_other)
  false
end

#to_sString

Generate string for Cisco IOS access list

Returns:

  • (String)


41
42
43
44
45
46
47
# File 'lib/cisco_acl_intp/acespec_port_opr_base.rb', line 41

def to_s
  tag_port(
    clean_acl_string(
      format('%s %s %s', @operator, @begin_port, @end_port)
    )
  )
end