Class: CommandBuilder::CodeGenerator::CommandCodeNames
- Inherits:
-
Object
- Object
- CommandBuilder::CodeGenerator::CommandCodeNames
- Defined in:
- lib/command_builder/code_generator/command_code_names.rb
Instance Method Summary collapse
- #command_factory_method_call ⇒ Object
- #command_factory_method_name ⇒ Object
- #command_factory_method_signature ⇒ Object
- #command_initializer_call ⇒ Object
- #command_module_name ⇒ Object
-
#initialize(command, version = nil) ⇒ CommandCodeNames
constructor
A new instance of CommandCodeNames.
- #version_factory_method_name ⇒ Object
- #version_factory_method_signature ⇒ Object
- #version_module_name ⇒ Object
Constructor Details
#initialize(command, version = nil) ⇒ CommandCodeNames
Returns a new instance of CommandCodeNames.
7 8 9 10 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 7 def initialize(command, version=nil) @command = command @compact_version = version.to_s.gsub('.', '') end |
Instance Method Details
#command_factory_method_call ⇒ Object
37 38 39 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 37 def command_factory_method_call format_method command_factory_method_name, initializer_values end |
#command_factory_method_name ⇒ Object
21 22 23 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 21 def command_factory_method_name @command.node_name.downcase.snakecase end |
#command_factory_method_signature ⇒ Object
25 26 27 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 25 def command_factory_method_signature format_method command_factory_method_name, factory_method_args end |
#command_initializer_call ⇒ Object
41 42 43 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 41 def command_initializer_call format_method "#{class_name}.new", %w(b) + initializer_values end |
#command_module_name ⇒ Object
12 13 14 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 12 def command_module_name @command.node_name.camelcase end |
#version_factory_method_name ⇒ Object
29 30 31 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 29 def version_factory_method_name "#{command_factory_method_name}_#{@compact_version.downcase.snakecase}" end |
#version_factory_method_signature ⇒ Object
33 34 35 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 33 def version_factory_method_signature format_method version_factory_method_name, factory_method_args end |
#version_module_name ⇒ Object
16 17 18 19 |
# File 'lib/command_builder/code_generator/command_code_names.rb', line 16 def version_module_name result = @compact_version =~ /^\d/ ? "V#{@compact_version}" : @compact_version result.camelcase end |