Hash
This class offers both Hash and OpenStruct functionality. We convert from the Core Hash to this before calling any of the display methods, in order to give the display methods a cleaner API for accessing the data.
This method converts from a Hash to an OpenStructHash.
# File rdoc/ri/driver.rb, line 24
def self.convert(object)
case object
when Hash then
new_hash = new # Convert Hash -> OpenStructHash
object.each do |key, value|
new_hash[key] = convert(value)
end
new_hash
when Array then
object.map do |element|
convert(element)
end
else
object
end
end
# File rdoc/ri/driver.rb, line 43
def merge_enums(other)
other.each do |k, v|
if self[k] then
case v
when Array then
# HACK dunno
if String === self[k] and self[k].empty? then
self[k] = v
else
self[k] += v
end
when Hash then
self[k].update v
else
# do nothing
end
else
self[k] = v
end
end
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.