Method: SwiftTools::Csharp2Swift#convert_if

Defined in:
lib/swift_tools/csharp_2_swift.rb

#convert_if(content) ⇒ Object



235
236
237
238
239
240
241
# File 'lib/swift_tools/csharp_2_swift.rb', line 235

def convert_if(content)
  content.gsub!(/if *\((.*)\) +\{/, 'if \\1 {')
  content.gsub!(/if *\((.*?)\)\n( +)(.*?)\n/m) { |m|
    s = $2.length > 4 ? $2[0...-4] : s
    'if ' + $1 + " {\n" + $2 + $3 + "\n" + s + "}\n"
  }
end