Class: PryCommandSetRegistry::Registry
- Inherits:
-
Object
- Object
- PryCommandSetRegistry::Registry
- Defined in:
- lib/pry_command_set_registry/registry.rb
Instance Attribute Summary collapse
-
#command_sets ⇒ Object
readonly
Returns the value of attribute command_sets.
Instance Method Summary collapse
- #command_set(name) ⇒ Object
- #define_command_set(name, description, &block) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 |
# File 'lib/pry_command_set_registry/registry.rb', line 5 def initialize @command_sets = {} end |
Instance Attribute Details
#command_sets ⇒ Object (readonly)
Returns the value of attribute command_sets.
3 4 5 |
# File 'lib/pry_command_set_registry/registry.rb', line 3 def command_sets @command_sets end |
Instance Method Details
#command_set(name) ⇒ Object
9 10 11 12 |
# File 'lib/pry_command_set_registry/registry.rb', line 9 def command_set(name) sanitized_name = name.to_s.sub(/^:/, "") command_sets[sanitized_name] end |
#define_command_set(name, description, &block) ⇒ Object
14 15 16 17 |
# File 'lib/pry_command_set_registry/registry.rb', line 14 def define_command_set(name, description, &block) command_set = CommandSet.new(name, description, &block) command_sets[command_set.name] = command_set end |