class String

Public Instance Methods

format_substring(substring, formatter, downcase: false) click to toggle source
# File lib/doublespeak/string.rb, line 14
def format_substring(substring, formatter, downcase: false)
  index = downcase ? self.downcase.index(substring.downcase) : index(substring)

  if index.nil?
    self
  else
    substring = self[index, substring.length]
    gsub(substring, formatter.call(substring))
  end
end
ljust_noescape(width, delim=" ") click to toggle source
# File lib/doublespeak/string.rb, line 6
def ljust_noescape(width, delim=" ")
  self + delim*(width - noescape.length)
end
noescape() click to toggle source
# File lib/doublespeak/string.rb, line 2
def noescape
  gsub(%r{\e[^m]*m}, '')
end
rjust_noescape(width, delim=" ") click to toggle source
# File lib/doublespeak/string.rb, line 10
def rjust_noescape(width, delim=" ")
  delim*(width - noescape.length) + self
end