class Helpr::Help
Attributes
top[RW]
Public Instance Methods
[](name)
click to toggle source
# File lib/helpr.rb, line 12 def [](name) help[name.to_sym] end
[]=(name, val)
click to toggle source
# File lib/helpr.rb, line 16 def []=(name, val) help[name.to_sym] = val end
add(name, text)
click to toggle source
# File lib/helpr.rb, line 7 def add(name, text) self[name] = text topics(name.split(' ')) end
help()
click to toggle source
# File lib/helpr.rb, line 20 def help @help ||= Hash.new end
hierarchy()
click to toggle source
# File lib/helpr.rb, line 49 def hierarchy @hierarchy ||= Hash.new end
topics(keys=nil)
click to toggle source
# File lib/helpr.rb, line 24 def topics(keys=nil) result = if keys.nil? hierarchy else topics_aux(keys, hierarchy) end result.keys end
topics_aux(keys, hier)
click to toggle source
# File lib/helpr.rb, line 33 def topics_aux(keys, hier) key = if keys.empty? '' else keys.shift.to_sym end hier = hier.fetch(key) do hier[key] = {} end if keys.empty? hier else topics_aux(keys, hier) end end