class SwiftGenerator::SwiftFile

A Swift File to be generated. This file contains one or more elements Elements can be classes (Future: Structs, Enums, Functions)

Attributes

company_name[RW]
elements[RW]
file_name[RW]
file_path[RW]
import_statements[RW]
include_editing_warnings[RW]
is_user_file[RW]

Public Class Methods

new(name, root_path, is_user_file:false, company_name:"<My Entity>") click to toggle source
# File lib/swift_generator/code_generation/swift_class_generation.rb, line 20
    def initialize (name, root_path, is_user_file:false, company_name:"<My Entity>")
            name += '.swift' unless name.end_with?( '.swift' )
            @file_name = name
            @file_path = File.join(root_path, @file_name)

#puts( "--- SwiftFile name = #{name} root_path = #{root_path} file_path = #{@file_path}" )

@is_user_file = is_user_file
            @elements = []
            @import_statements = []
@include_editing_warnings = false
@company_name = company_name
    end

Public Instance Methods

add_element(swift_class) click to toggle source
# File lib/swift_generator/code_generation/swift_class_generation.rb, line 34
def add_element(swift_class)
        @elements << swift_class
end
add_import(module_name) click to toggle source

@param [String] module_name

# File lib/swift_generator/code_generation/swift_class_generation.rb, line 53
def add_import(module_name)
        import_statement = "import #{module_name}"
        return if @import_statements.include?(import_statement)
        @import_statements << import_statement
end
prepare_for_generation() click to toggle source
# File lib/swift_generator/code_generation/swift_class_generation.rb, line 46
def prepare_for_generation
        @elements.each do |element|
                element.prepare_for_generation
        end
end
prepare_supporting_elements() click to toggle source

Called before all other generation-time methods. Give user-defined elements ( classes, etc. ) the opportunity to construct other related or required elements

# File lib/swift_generator/code_generation/swift_class_generation.rb, line 40
def prepare_supporting_elements
        @elements.each do |element|
                element.prepare_supporting_elements
        end
end