Class: SwiftGenerator::SwiftMethodBase

Inherits:
Object
  • Object
show all
Defined in:
lib/swift_generator/code_generation/swift_class_generation.rb

Direct Known Subclasses

SwiftInitializer, SwiftMethod

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(swift_element, name, argStr, returns, override: false, comment: nil) ⇒ SwiftMethodBase

Returns a new instance of SwiftMethodBase.



1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1304

def initialize (swift_element, name, argStr, returns, override: false, comment: nil)
	@name = name
	@argStr = argStr
	@returns = returns
	@override = override
	@comment = comment

	@indent = 0
	@bodyLines = []

	@access_control_modifier = ''
end

Instance Attribute Details

#access_control_modifierObject

Returns the value of attribute access_control_modifier.



1297
1298
1299
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1297

def access_control_modifier
  @access_control_modifier
end

#argStrObject

Returns the value of attribute argStr.



1292
1293
1294
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1292

def argStr
  @argStr
end

#bodyLinesObject

Returns the value of attribute bodyLines.



1301
1302
1303
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1301

def bodyLines
  @bodyLines
end

#commentObject

Returns the value of attribute comment.



1295
1296
1297
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1295

def comment
  @comment
end

#func_qualifiersObject

Returns the value of attribute func_qualifiers.



1298
1299
1300
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1298

def func_qualifiers
  @func_qualifiers
end

#indentObject

Returns the value of attribute indent.



1300
1301
1302
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1300

def indent
  @indent
end

#nameObject

Returns the value of attribute name.



1291
1292
1293
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1291

def name
  @name
end

#overrideObject

Returns the value of attribute override.



1293
1294
1295
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1293

def override
  @override
end

#returnsObject

Returns the value of attribute returns.



1294
1295
1296
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1294

def returns
  @returns
end

Instance Method Details

#<<(*line_or_lines) ⇒ Object



1318
1319
1320
1321
1322
1323
1324
1325
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1318

def << (*line_or_lines)
	line_or_lines = line_or_lines.flatten()
	line_or_lines.each do |line|
		new_line = ("\t" * @indent) + line
		@bodyLines << new_line
	end
	@bodyLines = @bodyLines.flatten()
end

#_i(*line_or_lines) ⇒ Object



1327
1328
1329
1330
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1327

def _i (*line_or_lines)
	@indent += 1
	self << line_or_lines
end

#_o(*line_or_lines) ⇒ Object



1332
1333
1334
1335
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1332

def _o (*line_or_lines)
	self << line_or_lines
	@indent -= 1
end

#func_fragmentObject



1343
1344
1345
1346
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1343

def func_fragment()
	return 'func' if func_qualifiers.nil?
	return [*func_qualifiers].join( ' ' ) + ' func'
end

#ii(*line_or_lines) ⇒ Object



1337
1338
1339
1340
1341
# File 'lib/swift_generator/code_generation/swift_class_generation.rb', line 1337

def ii (*line_or_lines)
	@indent += 1
	self << line_or_lines
	@indent -= 1
end