Class: CiscoAclIntp::NumberedAcl
- Inherits:
-
AclBase
- Object
- AccessControlContainer
- AclBase
- CiscoAclIntp::NumberedAcl
- Defined in:
- lib/cisco_acl_intp/acl_category_base.rb
Overview
Numbered ACL container base
Direct Known Subclasses
Constant Summary
Constants inherited from AclBase
Constants inherited from AccessControlContainer
AccessControlContainer::TERM_COLOR_TABLE
Instance Attribute Summary collapse
-
#number ⇒ Integer
readonly
Access list number.
Attributes inherited from AclBase
#acl_type, #list, #name, #name_type
Instance Method Summary collapse
-
#header_string ⇒ String
Generate ACL header string.
-
#initialize(name) ⇒ NumberedAcl
constructor
Constructor.
-
#line_string(entry) ⇒ Object
Generate ACL line string.
-
#named_acl? ⇒ Boolean
check acl type,Named ACL or not?.
-
#numbered_acl? ⇒ Boolean
check acl type, Numbered ACL or not?.
-
#set_name_and_number(name, number) ⇒ Object
private
Set instance variables.
-
#to_s ⇒ String
Generate string for Cisco IOS access list.
-
#validate_name_by_string(name) ⇒ Object
private
validate instance variables.
Methods inherited from AclBase
#==, #add_entry, #clean_acl_string, #dup_with_list, #find_aces_contained, #find_aces_contains, #find_aces_with, #renumber
Methods included from AceSearchUtility
#generate_port_obj, generate_port_obj, #port_spec_by_protocol, port_spec_by_protocol, ptkey, #ptkey, search_conditions, #search_conditions, select_proto_class, #select_proto_class, slice_contains_opts, #slice_contains_opts, #srcdst_condition, srcdst_condition, #target_ace, target_ace
Methods inherited from AccessControlContainer
#clean_acl_string, disable_color, #generate_tag_footer, #generate_tag_header, #generate_tagged_str, #method_missing
Constructor Details
#initialize(name) ⇒ NumberedAcl
It ought to do something about assignment operator… (attr_reader)
Constructor
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 100 def initialize(name) super case name when Fixnum set_name_and_number(name.to_s, name) when String validate_name_by_string(name) else raise AclArgumentError, 'acl number error' end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CiscoAclIntp::AccessControlContainer
Instance Attribute Details
#number ⇒ Integer (readonly)
Returns Access list number.
80 81 82 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 80 def number @number end |
Instance Method Details
#header_string ⇒ String
Generate ACL header string
114 115 116 117 118 119 120 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 114 def header_string format( '%s %s', tag_header('access-list'), tag_name(@name) ) end |
#line_string(entry) ⇒ Object
Generate ACL line string
124 125 126 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 124 def line_string(entry) clean_acl_string(format('%s %s', header_string, entry)) end |
#named_acl? ⇒ Boolean
check acl type,Named ACL or not?
84 85 86 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 84 def named_acl? false end |
#numbered_acl? ⇒ Boolean
check acl type, Numbered ACL or not?
90 91 92 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 90 def numbered_acl? true end |
#set_name_and_number(name, number) ⇒ Object (private)
Set instance variables
150 151 152 153 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 150 def set_name_and_number(name, number) @name = name @number = number end |
#to_s ⇒ String
Generate string for Cisco IOS access list
130 131 132 133 134 135 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 130 def to_s strings = @list.each_with_object([]) do |entry, strlist| strlist.push line_string(entry) end strings.join("\n") end |
#validate_name_by_string(name) ⇒ Object (private)
validate instance variables
141 142 143 144 145 146 147 |
# File 'lib/cisco_acl_intp/acl_category_base.rb', line 141 def validate_name_by_string(name) if name =~ /\A\d+\Z/ set_name_and_number(name, name.to_i) else raise AclArgumentError, 'acl number string is not integer' end end |