scottwillson/racing_on_rails

View on GitHub
app/helpers/whitespace_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module WhitespaceHelper
  def show_whitespace(text)
    return text unless text

    preceding_whitespace(text) + text.strip + trailing_whitespace(text)
  end

  def preceding_whitespace(text)
    "·" * (text[/\A\s+/] || "").size
  end

  def trailing_whitespace(text)
    "·" * (text[/\s+\z/] || "").size
  end
end