Sha256: 0927ad621618186707448792d3ffc1d11a7ca787d0d44a9a707c8e75d70f696d

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require_relative "concat_heredoc_horizontal/version"

module ConcatHeredocHorizontal
  class Error < StandardError; end
  # Your code goes here...
  def self.concat_simple(str_1, str_2)
    i = 0
    j = 0
    k = 0
    lim_sup = (str_1.count("\n") > str_2.count("\n"))? str_1.count("\n") : str_2.count("\n")
    str = ""
    str_result = str.dup

    while i <= lim_sup
      while j < str_1.length
        unless str_1[j].eql?("\n")
          str_result << str_1[j]
        else
          j += 1
          break
        end
        j += 1
      end

      while k < str_2.length
        unless str_2[k].eql?("\n")
          str_result << str_2[k]
        else
          k += 1
          break
        end
        k += 1
      end

      str_result << "\n"
      i += 1
    end

    return str_result.chomp
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
concat_heredoc_horizontal-0.1.1 lib/concat_heredoc_horizontal.rb
concat_heredoc_horizontal-0.1.0 lib/concat_heredoc_horizontal.rb