Class: Rex::Socket::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/socket/range_walker.rb

Overview

A range of IP addresses

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start = nil, stop = nil, options = nil) ⇒ Range



442
443
444
445
446
# File 'lib/rex/socket/range_walker.rb', line 442

def initialize(start=nil, stop=nil, options=nil)
  @start = start
  @stop = stop
  @options = options
end

Instance Attribute Details

#optionsHash



435
436
437
# File 'lib/rex/socket/range_walker.rb', line 435

def options
  @options
end

#startFixnum

The first address in this range, as a number



428
429
430
# File 'lib/rex/socket/range_walker.rb', line 428

def start
  @start
end

#stopFixnum

The last address in this range, as a number



432
433
434
# File 'lib/rex/socket/range_walker.rb', line 432

def stop
  @stop
end

Instance Method Details

#==(other) ⇒ Boolean

Compare attributes with other



451
452
453
# File 'lib/rex/socket/range_walker.rb', line 451

def ==(other)
  (other.start == start && other.stop == stop && other.ipv6? == ipv6? && other.options == options)
end

#ipv6?Boolean

Whether this Range contains IPv6 or IPv4 addresses



464
465
466
# File 'lib/rex/socket/range_walker.rb', line 464

def ipv6?
  options[:ipv6]
end

#lengthFixnum Also known as: count

The number of addresses in this Range



457
458
459
# File 'lib/rex/socket/range_walker.rb', line 457

def length
  stop - start + 1
end