class Hash

Access hash keys like they were class methods hash -> hash.key

Public Instance Methods

method_missing(m) click to toggle source
# File lib/resme/renderer/renderer.rb, line 139
def method_missing(m)
  key = m.to_s

  # error: nil value
  if self.has_key? key and self[key] == nil
    $stderr.puts "[W] The value of key '#{key}' is nil in the following entry:"

    # we put a bit of info about the top level structure of a resume to avoid extra-long error messages
    # I don't want to print detailed information about top-level entries missing in the resume
    top_level_entries = [
      "contacts", "addresses", "web_presence", "summary", "work", "teaching", "projects", "other",
      "committees", "volunteer", "visits", "education", "publications", "talks", "awards", "achievements",
      "software", "skills", "languages", "driving", "interests", "references"]
    if not top_level_entries.include?(key) then
      # $stderr.puts self.to_s
      self.keys.each do |k|
        $stderr.puts "  #{k}: #{self[k]}"
      end
      $stderr.puts ""
    end
  end

  return self[key] if self.has_key? key

  # we get here if the key is not found
  # we report an error, return "" and continue
  # the actual mileage might vary

  # more error reporting: key not found
  $stderr.puts "[E] Key '#{key}' not found in the following entry:"
  # $stderr.puts self.to_s
  self.keys.each do |k|
    $stderr.puts "  #{k}: #{self[k]}"
  end
  $stderr.puts ""

  return ""
end