Module: MetasploitDataModels::IPAddress::CIDR

Extended by:
ActiveModel::Naming, ActiveSupport::Concern
Included in:
V4::CIDR
Defined in:
lib/metasploit_data_models/ip_address/cidr.rb

Overview

Common behavior for Class-InterDomain Routing (<address>/<prefix-length>) notation under MetasploitDataModels::IPAddress,

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

SEPARATOR =

Separator between the #address and #prefix_length

'/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



23
24
25
# File 'lib/metasploit_data_models/ip_address/cidr.rb', line 23

def address
  @address
end

#prefix_lengthObject

Returns the value of attribute prefix_length.



29
30
31
# File 'lib/metasploit_data_models/ip_address/cidr.rb', line 29

def prefix_length
  @prefix_length
end

Instance Method Details

#prefix_length_before_type_cast#to_s

The formatted_prefix_length passed to #prefix_length=

Returns:

  • (#to_s)


148
149
150
# File 'lib/metasploit_data_models/ip_address/cidr.rb', line 148

def prefix_length_before_type_cast
  @prefix_length_before_type_cast
end

#value=(formatted_value) ⇒ Object

Parses the formatted_value into an #address and #prefix_length.

Parameters:

  • formatted_value (#to_s)


155
156
157
158
159
160
161
162
# File 'lib/metasploit_data_models/ip_address/cidr.rb', line 155

def value=(formatted_value)
  formatted_address, formatted_prefix_length = formatted_value.to_s.split(SEPARATOR, 2)

  self.address = formatted_address
  self.prefix_length = formatted_prefix_length

  [address, prefix_length]
end