class Whois::Scanners::Iana

Private Instance Methods

parse_section_pair() click to toggle source
# File lib/whois/scanners/iana.rb, line 69
def parse_section_pair
  if @input.scan(/^(.+):\s*(.+)\n/)
    key     =  @input[1].strip
    values  = [@input[2].strip]

    while value = parse_section_pair_newlinevalue(key)
      values << value
    end
    { key => values.join("\n") }
  end
end
parse_section_pair_newlinevalue(key) click to toggle source
# File lib/whois/scanners/iana.rb, line 81
def parse_section_pair_newlinevalue(key)
  if @input.scan(/^#{key}:\s*(.+)\n/)
    @input[1].strip
  end
end
parse_section_pairs() click to toggle source
# File lib/whois/scanners/iana.rb, line 45
def parse_section_pairs
  # Sets by default the firsts values found in the section parsing bellow
  section_name, section_value = @input[1].strip, @input[2].strip
  #contents = {section_name =>  section_value}

  contents = {}

  while content = parse_section_pair
    contents.merge!(content)
  end

  if contents.has_key? section_name
    contents[section_name].insert(0, "#{section_value}\n")
  else
    contents[section_name] = section_value
  end

  if !contents.empty?
    contents
  else
    false
  end
end