Sha256: 6412a08955bbec5077175b7a67619ab022622d4af6a780f33b92a0231fd64497

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

require 'amass/hostname'

module Amass
  module Parsers
    #
    # Parses single-line hostnames.
    #
    # @api semipublic
    #
    module TXT
      #
      # Parses a single line of plain-text.
      #
      # @param [IO] io
      #   The IO stream to parse.
      #
      # @yield [hostname]
      #   The given block will be passed each parsed hostname.
      #
      # @yieldparam [Hostname] hostname
      #   The parsed hostname.
      #
      # @return [Enumerator]
      #   If no block is given, an Enumerator will be returned.
      #
      def self.parse(io)
        return enum_for(__method__,io) unless block_given?

        io.each_line do |line|
          line.chomp!

          yield Hostname.new(name: line)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-amass-0.1.0 lib/amass/parsers/txt.rb