Sha256: ba20aba766ea90df7945d332c42ffe711ed1c7b24722470fb5ac0291d761c423
Contents?: true
Size: 698 Bytes
Versions: 3
Compression:
Stored size: 698 Bytes
Contents
class String def column_of(index) return 1 if index == 0 newline_index = rindex("\n", index - 1) if newline_index index - newline_index else index + 1 end end def line_of(index) self[0...index].count("\n") + 1 end # The following methods are lifted from Facets 2.0.2 def tabto(n) if self =~ /^( *)\S/ # Inlined due to collision with ActiveSupport 4.0: indent(n - $1.length) m = n - $1.length if m >= 0 gsub(/^/, ' ' * m) else gsub(/^ {0,#{-m}}/, "") end else self end end def treetop_camelize to_s.gsub(/\/(.?)/){ "::" + $1.upcase }.gsub(/(^|_)(.)/){ $2.upcase } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
treetop-1.6.14 | lib/treetop/ruby_extensions/string.rb |
treetop-1.6.12 | lib/treetop/ruby_extensions/string.rb |
treetop-1.6.11 | lib/treetop/ruby_extensions/string.rb |