Sha256: 34da0e8c7d73ef82e03f6878118fbda5a392e81ec9f8cfb59049c787d86e57a3
Contents?: true
Size: 699 Bytes
Versions: 1
Compression:
Stored size: 699 Bytes
Contents
# frozen_string_literal: true class String # Helper for the heredoc functionality. Allows pipe '|' delimeted heredocs # with a parameterized delimeter. # # Example: # html = <<-stop.here_with_pipe(delimeter="\n") # |<!-- Begin: comment --> # |<script type="text/javascript"> # stop # html == '<!-- Begin: comment -->\n<script type="text/javascript">' # # @param [String] delimeter Joins the lines of strings with this delimeter. # # @return [String] Returns the concatenated string. # def here_with_pipe!(delimeter = ' ') lines = split("\n") lines.map! { |c| c.sub!(/\s*\|/, '') } new_string = lines.join(delimeter) replace(new_string) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsonapi_rspec-0.2.3 | lib/jsonapi_rspec/string.rb |