So I have this code:
class Door
# ...
def info attr = ""
return {
"width" => @width,
"height" => @height,
"color" => @color
}[attr] if attr != ""
end
end
mydoor = Door.new(100, 100, "red")
puts mydoor.info("width")
puts mydoor.info
The method "info" should return the hash if no argument is provided, otherwise the value of the argument in the hash. How can I achieve that?