class String

Public Instance Methods

indent() click to toggle source
# File lib/guerrilla_patch/string.rb, line 15
def indent
  tokens = self.split ("\n")
  result = ''
  if tokens.size > 0 
    prespace_index = tokens[0].index(/\S/)
    tokens.each do |token|
      result << token[prespace_index,(token.length - prespace_index)] << "\n"
    end
  end
  return result
end
split_on_size(*args) click to toggle source
# File lib/guerrilla_patch/string.rb, line 2
def split_on_size(*args)
  regex = args.to_a.inject('') { |regex, size| regex += "(\\w{#{size}})" }
  split(Regexp.compile("^#{regex}$")).reject do |item|
    item.blank? 
  end.join('-')
end
upcase_roman() click to toggle source
# File lib/guerrilla_patch/string.rb, line 9
def upcase_roman
  self =~ /(.*)(_[xX]?[vV]?[iI]{0,3}[vV]?[xX]?)$/
  return self if $1.nil? || $2.nil?
  return $1 + $2.upcase
end