Class: SSLScan::Socket::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/ssl_scan/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

Returns a new instance of Range.

Parameters:

  • start (Fixnum) (defaults to: nil)
  • stop (Fixnum) (defaults to: nil)
  • options (Hash) (defaults to: nil)

    Recognized keys are:

    • :ipv6

    • :scope_id



441
442
443
444
445
# File 'lib/ssl_scan/socket/range_walker.rb', line 441

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

Instance Attribute Details

#optionsHash

Returns:

  • (Hash)


434
435
436
# File 'lib/ssl_scan/socket/range_walker.rb', line 434

def options
  @options
end

#startFixnum

The first address in this range, as a number

Returns:

  • (Fixnum)


427
428
429
# File 'lib/ssl_scan/socket/range_walker.rb', line 427

def start
  @start
end

#stopFixnum

The last address in this range, as a number

Returns:

  • (Fixnum)


431
432
433
# File 'lib/ssl_scan/socket/range_walker.rb', line 431

def stop
  @stop
end

Instance Method Details

#==(other) ⇒ Boolean

Compare attributes with other

Parameters:

Returns:

  • (Boolean)


450
451
452
# File 'lib/ssl_scan/socket/range_walker.rb', line 450

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

Returns:

  • (Boolean)


463
464
465
# File 'lib/ssl_scan/socket/range_walker.rb', line 463

def ipv6?
  options[:ipv6]
end

#lengthFixnum Also known as: count

The number of addresses in this Range

Returns:

  • (Fixnum)


456
457
458
# File 'lib/ssl_scan/socket/range_walker.rb', line 456

def length
  stop - start + 1
end