Sha256: e7cb039171da6583cc962baf08fea6ad32e17c3c01c9f281eb0c01e25d97886a

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module Nmap
  class Port

    # The protocol the port runs on
    attr_reader :protocol

    # The port number
    attr_reader :number

    # The state of the port
    attr_reader :state

    # The reason the port was discovered
    attr_reader :reason

    # The service the port provides
    attr_reader :service

    #
    # Creates a new Port object.
    #
    # @param [Integer] protocol
    #   The protocol the port runs on.
    #
    # @param [Integer] number
    #   The port number.
    #
    # @param [Symbol] state
    #   The state the port is in.
    #
    # @param [String] reason
    #   The reason for the ports state.
    #
    # @param [String] service
    #   The name of the service that runs on the port.
    #
    def initialize(protocol,number,state,reason,service=nil)
      @protocol = protocol
      @number = number
      @state = state
      @reason = reason
      @service = service
    end

    #
    # Converts the port to an Integer.
    #
    # @return [Integer]
    #   The port number.
    #
    def to_i
      @number.to_i
    end

    #
    # Converts the port to a String.
    #
    # @return [String]
    #   The port number.
    #
    def to_s
      @number.to_s
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-nmap-0.2.0 lib/nmap/port.rb
ruby-nmap-0.1.1 lib/nmap/port.rb
ruby-nmap-0.1.0 lib/nmap/port.rb