Sha256: f7cd80ef43deeabdb43fad15ac6c2325b93629b3c880b21a7d257b8acf1bea34
Contents?: true
Size: 702 Bytes
Versions: 3
Compression:
Stored size: 702 Bytes
Contents
module BabelBridge module StringExtensions def camelize self.split("_").collect {|a| a.capitalize}.join end def first_lines(n) lines=self.split("\n",-1) lines.length<=n ? self : lines[0..n-1].join("\n") end def last_lines(n) lines=self.split("\n",-1) lines.length<=n ? self : lines[-n..-1].join("\n") end # return the line and column of a given offset into this string # line and column are 1-based def line_col(offset) return 1,1 if length==0 || offset==0 lines=(self[0..offset-1]+" ").split("\n") return lines.length, lines[-1].length end end end class String include BabelBridge::StringExtensions end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
babel_bridge-0.4.1 | lib/string.rb |
babel_bridge-0.4.0 | lib/string.rb |
babel_bridge-0.3.1 | lib/string.rb |