Parent

Files

Class/Module Index [+]

Quicksearch

Whois::Record::Scanners::Base

Public Class Methods

new(content) click to toggle source
# File lib/whois/record/scanners/base.rb, line 24
def initialize(content)
  @input = StringScanner.new(content)
end
tokenizer(name, &block) click to toggle source
# File lib/whois/record/scanners/base.rb, line 19
def self.tokenizer(name, &block)
  define_method(name, &block)
end

Public Instance Methods

parse() click to toggle source
# File lib/whois/record/scanners/base.rb, line 28
def parse
  # The temporary store.
  # Scanners may use this to store pointers, states or other flags.
  @tmp = {}

  # A super-simple AST store.
  @ast = {}

  tokenize until @input.eos?

  @ast
end

Protected Instance Methods

_scan_keyvalues(pattern) click to toggle source
# File lib/whois/record/scanners/base.rb, line 89
def _scan_keyvalues(pattern)
  results = []
  while @input.scan(/(.+?):(.*?)\n/)
    key, value = @input[1].strip, @input[2].strip
    if results[key].nil?
      results[key] = value
    else
      results[key] = Array.wrap(results[key])
      results[key] << value
    end
  end
end
_scan_lines_to_array(pattern) click to toggle source
# File lib/whois/record/scanners/base.rb, line 72
def _scan_lines_to_array(pattern)
  results = []
  while @input.scan(pattern)
    @input[1].strip
    results << @input[1].strip
  end
  results
end
_scan_lines_to_hash(pattern) click to toggle source
# File lib/whois/record/scanners/base.rb, line 81
def _scan_lines_to_hash(pattern)
  results = {}
  while @input.scan(pattern)
    results.merge! @input[1].strip => @input[2].strip
  end
  results
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.