Sha256: bd092eaa4ede636a2e7ab942d87811cf5d11867ef69a0e1927a0f1223530bce3
Contents?: true
Size: 967 Bytes
Versions: 2
Compression:
Stored size: 967 Bytes
Contents
module Hirb # Provides string helpers to deal with UTF-8 and ruby 1.8.x module String extend self # :stopdoc: if RUBY_VERSION < '1.9' def size(string) string.scan(/./).length end def ljust(string, desired_length) leftover = desired_length - size(string) leftover > 0 ? string + " " * leftover : string end def rjust(string, desired_length) leftover = desired_length - size(string) leftover > 0 ? " " * leftover + string : string end def slice(string, start, finish) string.scan(/./).slice(start, finish).join('') end else def size(string) string.length end def ljust(string, desired_length) string.ljust(desired_length) end def rjust(string, desired_length) string.rjust(desired_length) end def slice(*args) string.slice(*args) end end #:startdoc: end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
cldwalker-hirb-0.2.3 | lib/hirb/string.rb |
hirb-0.2.3 | lib/hirb/string.rb |