Sha256: 6ceb54c49ce859e03b76871d30085388870d010d9978392a7db7de6fdcb113bc

Contents?: true

Size: 807 Bytes

Versions: 4

Compression:

Stored size: 807 Bytes

Contents

def add_auto_return_statement(input_array)

  joined_array = input_array.join

  reversed_input_array = input_array.reverse

  if !joined_array.include?("return ")

    rejected_array = reversed_input_array.reject { |content| content.lstrip.eql?("") }

    rejected_array = rejected_array.reject {|content| content.strip.eql?("")}

    rejected_array = rejected_array[1..-1]

    unless rejected_array[0].strip.eql?("}") or rejected_array[0].strip.eql?("})")

      if !rejected_array[0].strip.eql?("end") and !rejected_array[0].strip.include?("--single_line_comment")

        last_statement = rejected_array[0]

        replacement_string = "return #{last_statement.lstrip}"

        input_array[input_array.index(last_statement)] = replacement_string

      end

    end

  end

  return input_array

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nilac-0.0.4.3.9.8 lib/nilac/add_auto_return_statement.rb
nilac-0.0.4.3.9.7.1 lib/nilac/add_auto_return_statement.rb
nilac-0.0.4.3.9.7 lib/nilac/add_auto_return_statement.rb
nilac-0.0.4.3.9.6 lib/nilac/add_auto_return_statement.rb