Class: BaseCommandHandler
- Inherits:
-
Object
- Object
- BaseCommandHandler
- Defined in:
- lib/advanced_ruby_command_handler/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commands_dir ⇒ Object
Returns the value of attribute commands_dir.
-
#commands_module_name ⇒ Object
readonly
Returns the value of attribute commands_module_name.
-
#events_dir ⇒ Object
Returns the value of attribute events_dir.
-
#events_module_name ⇒ Object
readonly
Returns the value of attribute events_module_name.
Instance Method Summary collapse
- #get_module_by_string(module_name) ⇒ Object
-
#initialize(options) ⇒ BaseCommandHandler
constructor
A new instance of BaseCommandHandler.
Constructor Details
#initialize(options) ⇒ BaseCommandHandler
Returns a new instance of BaseCommandHandler.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 35 def initialize() %i[commands_dir events_dir commands_module_name events_module_name].each do |dir| raise Errors::MissingParameter.new(dir, "Parameter '#{dir}' unspecified") unless [dir] end @commands_dir = [:commands_dir] @events_dir = [:events_dir] @commands_module_name = [:commands_module_name] @events_module_name = [:events_module_name] FileUtils.mkdir_p [@commands_dir, @events_dir] end |
Instance Attribute Details
#commands_dir ⇒ Object
Returns the value of attribute commands_dir.
32 33 34 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 32 def commands_dir @commands_dir end |
#commands_module_name ⇒ Object (readonly)
Returns the value of attribute commands_module_name.
33 34 35 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 33 def commands_module_name @commands_module_name end |
#events_dir ⇒ Object
Returns the value of attribute events_dir.
32 33 34 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 32 def events_dir @events_dir end |
#events_module_name ⇒ Object (readonly)
Returns the value of attribute events_module_name.
33 34 35 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 33 def events_module_name @events_module_name end |
Instance Method Details
#get_module_by_string(module_name) ⇒ Object
46 47 48 49 50 |
# File 'lib/advanced_ruby_command_handler/base.rb', line 46 def get_module_by_string(module_name) raise Errors::NonExistingModule.new(module_name, "Module '#{module_name}' doesn't exist. Please specify an existing module") unless Object.const_defined?(module_name) Object.const_get(module_name) end |