lib/core/facets/string/nchar.rb in facets-2.4.5 vs lib/core/facets/string/nchar.rb in facets-2.5.0
- old
+ new
@@ -10,11 +10,9 @@
# str = "this is text"
# str.nchar(4) #=> "this"
# str.nchar(4, 'that') #=> "that"
# str #=> "that is text"
#
- # CREDIT: ?
-
def nchar(n, replacement=nil)
if replacement
s = self.dup
n > 0 ? (s[0...n] = replacement) : (s[n..-1] = replacement)
return s