Class: Property

Inherits:
Object
  • Object
show all
Defined in:
lib/swift_republic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(struct, declaration_String) ⇒ Property

Returns a new instance of Property.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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

Instance Attribute Details

#associated_structObject

Returns the value of attribute associated_struct.



6
7
8
# File 'lib/swift_republic.rb', line 6

def associated_struct
  @associated_struct
end

#declaration_StringObject

Returns the value of attribute declaration_String.



6
7
8
# File 'lib/swift_republic.rb', line 6

def declaration_String
  @declaration_String
end

#leading_spaces_countObject

Returns the value of attribute leading_spaces_count.



7
8
9
# File 'lib/swift_republic.rb', line 7

def leading_spaces_count
  @leading_spaces_count
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/swift_republic.rb', line 7

def name
  @name
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/swift_republic.rb', line 7

def type
  @type
end