Class: Ronin::Recon::Values::IPRange
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::IPRange
- Defined in:
- lib/ronin/recon/values/ip_range.rb
Overview
Represents a IP CIDR or glob range.
Instance Attribute Summary collapse
-
#range ⇒ Ronin::Support::Network::IPRange
readonly
The IP range.
Class Method Summary collapse
-
.value_type ⇒ :ip_range
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the IP range value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value of the IP range.
-
#include?(ip) ⇒ Boolean
Determines if an IP address exists within the IP range.
-
#initialize(range) ⇒ IPRange
constructor
Initializes the IP range object.
-
#to_s ⇒ String
(also: #to_str)
Converts the IP range object to a String.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(range) ⇒ IPRange
Initializes the IP range object.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ronin/recon/values/ip_range.rb', line 51 def initialize(range) @range = case range when Support::Network::IPRange range when String Support::Network::IPRange.new(range) else raise(ArgumentError,"IP range must be either an IPAddr or String: #{range.inspect}") end end |
Instance Attribute Details
#range ⇒ Ronin::Support::Network::IPRange (readonly)
The IP range.
39 40 41 |
# File 'lib/ronin/recon/values/ip_range.rb', line 39 def range @range end |
Class Method Details
.value_type ⇒ :ip_range
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
148 149 150 |
# File 'lib/ronin/recon/values/ip_range.rb', line 148 def self.value_type :ip_range end |
Instance Method Details
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
86 87 88 89 90 91 92 |
# File 'lib/ronin/recon/values/ip_range.rb', line 86 def ===(other) case other when IPRange then @range === other.range when IP then include?(other.address) else false end end |
#as_json ⇒ Hash{Symbol => Object}
Coerces the IP range value into JSON.
133 134 135 |
# File 'lib/ronin/recon/values/ip_range.rb', line 133 def as_json {type: :ip_range, range: @range.to_s} end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
101 102 103 |
# File 'lib/ronin/recon/values/ip_range.rb', line 101 def eql?(other) other.kind_of?(self.class) && @range == other.range end |
#hash ⇒ Integer
The "hash" value of the IP range.
111 112 113 |
# File 'lib/ronin/recon/values/ip_range.rb', line 111 def hash [self.class, @range].hash end |
#include?(ip) ⇒ Boolean
Determines if an IP address exists within the IP range.
71 72 73 |
# File 'lib/ronin/recon/values/ip_range.rb', line 71 def include?(ip) @range.include?(ip) end |
#to_s ⇒ String Also known as: to_str
Converts the IP range object to a String.
121 122 123 |
# File 'lib/ronin/recon/values/ip_range.rb', line 121 def to_s @range.to_s end |