Module: MetasploitDataModels::Match::Child
- Included in:
- IPAddress::CIDR::ClassMethods, IPAddress::V4::Range, IPAddress::V4::Segment::Nmap::Range, IPAddress::V4::Segment::Single, IPAddress::V4::Segmented
- Defined in:
- lib/metasploit_data_models/match/child.rb
Overview
Adds a match class method to the extending class. The extending class must define MATCH_REGEXP
.
Instance Method Summary collapse
-
#match(formatted_value) ⇒ Object
Creates a new instance of the extending class if
MATCH_REGEXP
, defined on the extending class, matchesformatted_value
. -
#match_regexp ⇒ Regexp
Regular expression to match against for #match.
-
#regexp ⇒ Regexp
Regular expression to match child as part of Parent.
Instance Method Details
#match(formatted_value) ⇒ Object
Creates a new instance of the extending class if MATCH_REGEXP
, defined on the extending class, matches
formatted_value
.
25 26 27 28 29 30 31 32 33 |
# File 'lib/metasploit_data_models/match/child.rb', line 25 def match(formatted_value) instance = nil if match_regexp.match(formatted_value) instance = new(value: formatted_value) end instance end |
#match_regexp ⇒ Regexp
Regular expression to match against for #match.
38 39 40 |
# File 'lib/metasploit_data_models/match/child.rb', line 38 def match_regexp @match_regexp ||= /\A#{regexp}\z/ end |
#regexp ⇒ Regexp
Regular expression to match child as part of Parent.
45 46 47 |
# File 'lib/metasploit_data_models/match/child.rb', line 45 def regexp self::REGEXP end |