Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/resme/renderer/renderer.rb
Overview
Access hash keys like they were class methods hash -> hash.key
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# 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 |