Class: IpValidator
- Inherits:
-
Object
- Object
- IpValidator
- Includes:
- Constants
- Defined in:
- lib/log_parser/ip_validator.rb
Overview
Validates ip addresses
Constant Summary
Constants included from Constants
Constants::DEFAULT_LOG, Constants::DEFAULT_OPTIONS, Constants::DESCRIPTORS, Constants::INFO_TITLES, Constants::LOG_WARNINGS, Constants::OPTION_DESCRIPTIONS, Constants::OUTPUT_COLORS, Constants::VALIDATION_NAMES, Constants::VALID_ADDRESS, Constants::VALID_IP4, Constants::VALID_IP6, Constants::VALID_LOG, Constants::VALID_PATH, Constants::WARNINGS_JSON, Constants::WARNING_COLORS
Instance Attribute Summary collapse
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#validation ⇒ Object
readonly
Returns the value of attribute validation.
Instance Method Summary collapse
-
#initialize(ip_address:, validation:) ⇒ IpValidator
constructor
A new instance of IpValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(ip_address:, validation:) ⇒ IpValidator
Returns a new instance of IpValidator.
9 10 11 12 |
# File 'lib/log_parser/ip_validator.rb', line 9 def initialize(ip_address:, validation:) @ip_address = ip_address @validation = VALID_ADDRESS[validation || :none] end |
Instance Attribute Details
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
7 8 9 |
# File 'lib/log_parser/ip_validator.rb', line 7 def ip_address @ip_address end |
#validation ⇒ Object (readonly)
Returns the value of attribute validation.
7 8 9 |
# File 'lib/log_parser/ip_validator.rb', line 7 def validation @validation end |
Instance Method Details
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/log_parser/ip_validator.rb', line 14 def valid? @validation.call(ip_address) end |