class Property

Attributes

associated_struct[RW]
declaration_String[RW]
leading_spaces_count[RW]
name[RW]
type[RW]

Public Class Methods

new(struct, declaration_String) click to toggle source
# File lib/swift_republic.rb, line 9
def initialize(struct, declaration_String)
        @associated_struct = struct
        indent_offset = declaration_String =~ /\S/ # Any non-whitespace character
        @leading_spaces_count = indent_offset
        @declaration_String = declaration_String.strip # Eg. "var sourceOfIncome: String"

        if declaration_String.include? ":"
                arr = declaration_String.split(":")
                name = arr.first.split(" ").last
                @name = name
                right_of_first_colon = arr.drop(1).join(":").strip
                @type = right_of_first_colon.split("//").first.strip
        else
                @name = "" 
                @type = ""
                p "Inferred types cannot be handled by the script -->  #{declaration_String}"
        end
end