Class: Rex::Socket::Range

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

Overview

A range of IP addresses

Direct Known Subclasses

Host

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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



512
513
514
515
516
# File 'lib/rex/socket/range_walker.rb', line 512

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

Instance Attribute Details

#optionsHash



505
506
507
# File 'lib/rex/socket/range_walker.rb', line 505

def options
  @options
end

#startFixnum

The first address in this range, as a number



498
499
500
# File 'lib/rex/socket/range_walker.rb', line 498

def start
  @start
end

#stopFixnum

The last address in this range, as a number



502
503
504
# File 'lib/rex/socket/range_walker.rb', line 502

def stop
  @stop
end

Instance Method Details

#==(other) ⇒ Boolean

Compare attributes with other



521
522
523
# File 'lib/rex/socket/range_walker.rb', line 521

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



534
535
536
# File 'lib/rex/socket/range_walker.rb', line 534

def ipv6?
  options[:ipv6]
end

#lengthFixnum Also known as: count

The number of addresses in this Range



527
528
529
# File 'lib/rex/socket/range_walker.rb', line 527

def length
  stop - start + 1
end