Sha256: ecdbe368fab92d9f81f364f31fb0469fc4ec17493d49945090f152075e45639b

Contents?: true

Size: 885 Bytes

Versions: 22

Compression:

Stored size: 885 Bytes

Contents

class String
  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

  def upcase_roman
    self =~ /(.*)(_[xX]?[vV]?[iI]{0,3}[vV]?[xX]?)$/
    return self if $1.nil? || $2.nil?
    return $1 + $2.upcase
  end

  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
end

class Symbol
  def upcase_roman() self.to_s.upcase_roman end
end

class Object
 def class_name_upcase_roman() return self.class.to_s.underscore.upcase_roman.to_sym end
end

module Kernel
  def plural(item) item.count > 1 ? 's' : '' end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
guerrilla_patch-3.0.3 lib/guerrilla_patch/string.rb
guerrilla_patch-3.0.2 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.7 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.6 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.5 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.4 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.3 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.2 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.1 lib/guerrilla_patch/string.rb
guerrilla_patch-2.8.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.7.1 lib/guerrilla_patch/string.rb
guerrilla_patch-2.7.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.6.2 lib/guerrilla_patch/string.rb
guerrilla_patch-2.6.1 lib/guerrilla_patch/string.rb
guerrilla_patch-2.6.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.5.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.4.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.3.1 lib/guerrilla_patch/string.rb
guerrilla_patch-2.3.0 lib/guerrilla_patch/string.rb
guerrilla_patch-2.2.0 lib/guerrilla_patch/string.rb