class String
Public Instance Methods
unindent()
click to toggle source
# File lib/activefacts/support.rb, line 150 def unindent indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0 self.gsub(/^[[:blank:]]{#{indent}}/, '') end
words()
click to toggle source
# File lib/activefacts/support.rb, line 132 def words Words.new( self. split( %r{ # Split and discard any group of non-alphanumeric characters: (?:[^[:alnum:]]+) | # Split between an uppercase and a preceding lowercase or digit: (?<=[[:lower:][:digit:]])(?=[[:upper:]]) | # Split between any alphanumeric and a following upper-lower pair: (?<=[[:alnum:]])(?=[[:upper:]][[:lower:]]) }x ). reject{|w| w == '' }. # Any word that starts with a digit gets an _ map{|w| w =~ /^[^_[:alpha:]]/ ? '_'+w : w} ) end