Class: CommandBuilder::CodeGenerator::CommandCodeNames

Inherits:
Object
  • Object
show all
Defined in:
lib/command_builder/code_generator/command_code_names.rb

Instance Method Summary collapse

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_callObject



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_nameObject



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_signatureObject



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_callObject



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_nameObject



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_nameObject



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_signatureObject



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_nameObject



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