Module: MetasploitDataModels::IPAddress::Range::ClassMethods

Defined in:
lib/metasploit_data_models/ip_address/range.rb

Overview

Class methods added to the including Class.

Instance Method Summary collapse

Instance Method Details

#extreme_classClass

Note:

Call #extremes first to set #extreme_class_name.

The Class for each extreme (Range#begin and Range#end) of the range.

Returns:

  • (Class)


71
72
73
# File 'lib/metasploit_data_models/ip_address/range.rb', line 71

def extreme_class
  @extreme_class ||= extreme_class_name.constantize
end

#extreme_class_nameString?

The name of #extreme_class.

Returns:

  • (String)

    Class#name passed to :class_name key when #extremes was called.

  • (nil)

    if #extremes has not been called.



79
80
81
# File 'lib/metasploit_data_models/ip_address/range.rb', line 79

def extreme_class_name
  @extreme_class_name
end

#extremes(options = {}) ⇒ void

This method returns an undefined value.

Sets #extreme_class_name.

Examples:

Setting extremes class name

extremes class_name: 'MetasploitDataModels::IPAddress::V4::Single'

Parameters:

  • options (Hash{Symbol => String}) (defaults to: {})

Options Hash (options):



91
92
93
94
95
# File 'lib/metasploit_data_models/ip_address/range.rb', line 91

def extremes(options={})
  options.assert_valid_keys(:class_name)

  @extreme_class_name = options.fetch(:class_name)
end

#match_regexpRegexp

Note:

Call #extremes first to set #extreme_class_name.

Regular expression that matches a string exactly when it contains an IP address range with the correct #extreme_class.

Returns:

  • (Regexp)

    #regexp pinned with '\A' and '\z' to the whole String.



62
63
64
# File 'lib/metasploit_data_models/ip_address/range.rb', line 62

def match_regexp
  @match_regexp ||= /\A#{regexp}\z/
end

#regexpRegexp

Note:

Call #extremes first to set #extreme_class_name.

Regular expression match a SEPARATOR separated range with #extreme_class parseable Range#begin and Range#end.

Returns:

  • (Regexp)


103
104
105
# File 'lib/metasploit_data_models/ip_address/range.rb', line 103

def regexp
  @regexp ||= /#{extreme_class.regexp}#{SEPARATOR}#{extreme_class.regexp}/
end