Sha256: 2ca946837811d92dd2c59cb343b08837bb98736c76cd8f27b236247d719aa65f
Contents?: true
Size: 960 Bytes
Versions: 2
Compression:
Stored size: 960 Bytes
Contents
# # Installs _wlang_ utility methods on Ruby String. # class String # Converts the string to a wlang template def wlang_template(dialect = "wlang/active-string", block_symbols = :braces) WLang::template(self, dialect, block_symbols) end # # Instantiates the string as a wlang template using # a context object and a dialect. # def wlang_instantiate(context = nil, dialect = "wlang/active-string", block_symbols = :braces) WLang::instantiate(self, context, dialect, block_symbols) end alias :wlang :wlang_instantiate # Computes the column number for a given offset in # this string def __wlang_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 # Computes the line number for a given offset in # this string def __wlang_line_of(index) self[0...index].count("\n") + 1 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wlang-0.9.2 | lib/wlang/ext/string.rb |
wlang-0.9.1 | lib/wlang/ext/string.rb |