Class: KCommercial::Resources::OCGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_model, name, keys, resources_status, options) ⇒ OCGenerator

Returns a new instance of OCGenerator.



14
15
16
17
18
19
20
# File 'lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb', line 14

def initialize(file_model, name, keys, resources_status, options)
  @file_model = file_model
  @name = name
  @keys = keys
  @super_module_name = options.delete(:super) { :KCSemanticResources }
  @resources_status = resources_status
end

Class Method Details

.templates_rootObject



9
10
11
# File 'lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb', line 9

def templates_root
  Pathname(__FILE__).parent.join('templates')
end

Instance Method Details

#code_modelObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb', line 30

def code_model
  @code_model ||= begin
                    model = CodeModel.new
                    model.keys = @keys
                    model.super_module_name = @super_module_name
                    model.component_name = @name
                    model.resources_status = @resources_status
                    model
                  end
end

#header_contentsObject



22
23
24
# File 'lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb', line 22

def header_contents
  ERB.new(File.read(@file_model.header)).result(code_model.get_binding)
end

#imp_contentsObject



26
27
28
# File 'lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb', line 26

def imp_contents
  ERB.new(File.read(@file_model.implementation)).result(code_model.get_binding)
end