Class: ModelDefinition
- Inherits:
-
Object
- Object
- ModelDefinition
- Defined in:
- lib/translate2language.rb,
lib/translate2OC.rb,
lib/translate2java.rb
Overview
代码生成器
Direct Known Subclasses
Instance Attribute Summary collapse
-
#configHash ⇒ Object
Returns the value of attribute configHash.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
-
#class_name ⇒ Object
类名.
-
#finishTranslate ⇒ Object
结束转换.
-
#header ⇒ Object
头文件生成.
-
#header_template ⇒ Object
头文件模版.
-
#implementation ⇒ Object
实现文件生成.
-
#implementation_template ⇒ Object
实现文件模版.
-
#initialize ⇒ ModelDefinition
constructor
A new instance of ModelDefinition.
-
#processTranslate ⇒ Object
处理转换.
-
#property_definition(readonly, args) ⇒ Object
属性模板.
-
#property_type(property) ⇒ Object
属性类型模板.
-
#propterty_getterGenerator(args) ⇒ Object
属性访问器模版.
-
#setcontext(context) ⇒ Object
生成器上下文.
-
#startTranslate(jsonFilePath) ⇒ Object
开始转换.
Constructor Details
#initialize ⇒ ModelDefinition
Returns a new instance of ModelDefinition.
39 40 41 |
# File 'lib/translate2language.rb', line 39 def initialize end |
Instance Attribute Details
#configHash ⇒ Object
Returns the value of attribute configHash.
30 31 32 |
# File 'lib/translate2language.rb', line 30 def configHash @configHash end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
57 58 59 |
# File 'lib/translate2language.rb', line 57 def context @context end |
Class Method Details
.getModelDefinition(modelType) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/translate2language.rb', line 31 def self.getModelDefinition(modelType) case modelType when "oc" modelDefinition = OCModelDefinition.new when "java" modelDefinition = JAVAModelDefinition.new end end |
Instance Method Details
#class_name ⇒ Object
类名
53 54 55 |
# File 'lib/translate2language.rb', line 53 def class_name context.class_name end |
#finishTranslate ⇒ Object
结束转换
107 108 109 110 |
# File 'lib/translate2language.rb', line 107 def finishTranslate end |
#header ⇒ Object
头文件生成
43 44 45 46 |
# File 'lib/translate2language.rb', line 43 def header erb_template = ERB.new(header_template, nil, '-') erb_template.result(binding) end |
#header_template ⇒ Object
头文件模版
77 78 79 |
# File 'lib/translate2language.rb', line 77 def header_template end |
#implementation ⇒ Object
实现文件生成
48 49 50 51 |
# File 'lib/translate2language.rb', line 48 def implementation erb_template = ERB.new(implementation_template, nil, '-') erb_template.result(binding) end |
#implementation_template ⇒ Object
实现文件模版
81 82 83 |
# File 'lib/translate2language.rb', line 81 def implementation_template end |
#processTranslate ⇒ Object
处理转换
98 99 100 101 102 103 104 105 |
# File 'lib/translate2language.rb', line 98 def processTranslate @configHash.each do |key,value| setcontext(Context.new(key,value)) finishTranslate end end |
#property_definition(readonly, args) ⇒ Object
属性模板
63 64 65 |
# File 'lib/translate2language.rb', line 63 def property_definition(readonly, args) end |
#property_type(property) ⇒ Object
属性类型模板
72 73 74 |
# File 'lib/translate2language.rb', line 72 def property_type(property) end |
#propterty_getterGenerator(args) ⇒ Object
属性访问器模版
67 68 69 |
# File 'lib/translate2language.rb', line 67 def propterty_getterGenerator(args) end |
#setcontext(context) ⇒ Object
生成器上下文
59 60 61 |
# File 'lib/translate2language.rb', line 59 def setcontext(context) @context = context end |
#startTranslate(jsonFilePath) ⇒ Object
开始转换
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/translate2language.rb', line 87 def startTranslate(jsonFilePath) begin jsonData = File.read(jsonFilePath) jsonObj = JSON.parse(jsonData) @configHash = jsonObj processTranslate rescue puts("配置文件格式出错") end end |