Class: CiscoAclIntp::StandardAce
- Inherits:
-
AceBase
- Object
- AccessControlContainer
- AceBase
- CiscoAclIntp::StandardAce
- Defined in:
- lib/cisco_acl_intp/ace_standard.rb
Overview
ACE for standard access list
Direct Known Subclasses
Constant Summary
Constants inherited from AceBase
Constants inherited from AccessControlContainer
AccessControlContainer::TERM_COLOR_TABLE
Instance Attribute Summary collapse
Attributes inherited from AceBase
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#contains?(other) ⇒ Boolean
Search matched ACE.
-
#define_action ⇒ String
private
Set instance variables.
-
#define_log_spec ⇒ String
private
Set instance variables.
-
#define_src_spec ⇒ AceSrcDstSpec
private
Set instance variables.
-
#initialize(opts) ⇒ StandardAce
constructor
Constructor.
-
#to_s ⇒ String
Generate string for Cisco IOS access list.
Methods inherited from AceBase
Methods inherited from AccessControlContainer
#clean_acl_string, disable_color, #generate_tag_footer, #generate_tag_header, #generate_tagged_str, #method_missing
Constructor Details
#initialize(opts) ⇒ StandardAce
Constructor
28 29 30 31 32 33 34 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 28 def initialize(opts) super @options = opts @action = define_action @src_spec = define_src_spec @log_spec = define_log_spec end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CiscoAclIntp::AccessControlContainer
Instance Attribute Details
#action ⇒ String
9 10 11 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 9 def action @action end |
#log_spec ⇒ AceLogSpec
17 18 19 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 17 def log_spec @log_spec end |
#src_spec ⇒ AceSrcDstSpec
13 14 15 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 13 def src_spec @src_spec end |
Instance Method Details
#==(other) ⇒ Boolean
37 38 39 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 37 def ==(other) @action == other.action && @src_spec == other.src_spec end |
#contains?(other) ⇒ Boolean
Search matched ACE
55 56 57 58 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 55 def contains?(other) other.is_a?(StandardAce) && @src_spec.contains?(other.src_spec) end |
#define_action ⇒ String (private)
Set instance variables
65 66 67 68 69 70 71 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 65 def define_action if @options.key?(:action) @options[:action] else raise AclArgumentError, 'Not specified action' end end |
#define_log_spec ⇒ String (private)
Set instance variables
95 96 97 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 95 def define_log_spec @options[:log] || nil end |
#define_src_spec ⇒ AceSrcDstSpec (private)
Set instance variables
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 76 def define_src_spec if @options.key?(:src) src = @options[:src] case src when Hash AceSrcDstSpec.new(src) when AceSrcDstSpec src else raise AclArgumentError, 'src spec: unknown class' end else raise AclArgumentError, 'Not specified src spec' end end |
#to_s ⇒ String
Generate string for Cisco IOS access list
43 44 45 46 47 48 49 50 |
# File 'lib/cisco_acl_intp/ace_standard.rb', line 43 def to_s format( '%s %s %s', tag_action(@action.to_s), @src_spec, tag_other_qualifier(@log_spec ? @log_spec : '') ) end |