class ModelDefinition

代码生成器

Attributes

configHash[RW]
context[R]

Public Class Methods

getModelDefinition(modelType) click to toggle source
# File lib/translate2language.rb, line 31
def self.getModelDefinition(modelType)
    case modelType
    when "oc"
        modelDefinition = OCModelDefinition.new
    when "java"
        modelDefinition = JAVAModelDefinition.new
    end
end
new() click to toggle source
# File lib/translate2language.rb, line 39
def initialize

end

Public Instance Methods

class_name() click to toggle source

类名

# File lib/translate2language.rb, line 53
def class_name
    context.class_name
end
finishTranslate() click to toggle source

结束转换

# File lib/translate2language.rb, line 107
def finishTranslate


end
header() click to toggle source

头文件生成

# File lib/translate2language.rb, line 43
def header
    erb_template = ERB.new(header_template, nil, '-')
    erb_template.result(binding)
end
header_template() click to toggle source

头文件模版

# File lib/translate2language.rb, line 77
def header_template
    
end
implementation() click to toggle source

实现文件生成

# File lib/translate2language.rb, line 48
def implementation
    erb_template = ERB.new(implementation_template, nil, '-')
    erb_template.result(binding)
end
implementation_template() click to toggle source

实现文件模版

# File lib/translate2language.rb, line 81
def implementation_template

end
processTranslate() click to toggle source

处理转换

# 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) click to toggle source

属性模板

# File lib/translate2language.rb, line 63
def property_definition(readonly, args)
    
end
property_type(property) click to toggle source

属性类型模板

# File lib/translate2language.rb, line 72
def property_type(property)

end
propterty_getterGenerator(args) click to toggle source

属性访问器模版

# File lib/translate2language.rb, line 67
def propterty_getterGenerator(args)

end
setcontext(context) click to toggle source

生成器上下文

# File lib/translate2language.rb, line 59
def setcontext(context)
    @context = context
end
startTranslate(jsonFilePath) click to toggle source

开始转换

# 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