class Moblues::Generator::Swift::Base
Attributes
type[R]
Public Class Methods
new()
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 8 def initialize @type = Generator::Base::Type.new end
Protected Instance Methods
file_path(output_dir, entity)
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 25 def file_path(output_dir, entity) raise NotImplemented end
render(entity, file_type)
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 29 def render(entity, file_type) ERB.new(template(file_type), 0, '-').result(entity.send(:binding)) end
template(file_type)
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 33 def template(file_type) File.read(File.expand_path("../#{file_type}.swift.erb", __FILE__)) end
write_file(file, text)
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 19 def write_file(file, text) File.open(file, 'w+') do |f| f.write(text) end end
write_swift(output_dir, entity, file_type)
click to toggle source
# File lib/moblues/generator/swift/base.rb, line 15 def write_swift(output_dir, entity, file_type) write_file(file_path(output_dir, entity), render(entity, file_type)) end