Sha256: 4c8cad5a23ac414e42436797263379167b1c65091f9bd843d0b9c2b0e79dab6d
Contents?: true
Size: 708 Bytes
Versions: 1
Compression:
Stored size: 708 Bytes
Contents
# frozen_string_literal: true # Adds function to existing String class class String # output the string giving the limit. It does not touch the string def limit_print(limit: 32, more_indicator: '.', indicator_length: 3) return self if size < limit [self[0...limit], (more_indicator * indicator_length)].join end # outputs an array def to_smart_array(separator = nil) return [] if nil? return split(separator).map(&:strip) unless separator.nil? return split(',').map(&:strip) if include?(',') split.map(&:strip) end # outputs string where it replaces \n or \r with actual return def escaped_newline_to_newline self.gsub('\n', "\n").gsub('\r', "\n") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
render-text-helper-0.3.2 | lib/render/text/helper/string.rb |