class String
Constants
- LOCAL_BLANK_RE
Public Instance Methods
blank?()
click to toggle source
A string is blank if it's empty or contains whitespaces only:
''.blank? # => true ' '.blank? # => true "\t\n\r".blank? # => true ' blah '.blank? # => false
Unicode whitespace is supported:
"\u00a0".blank? # => true
@return [true, false]
# File lib/dns_one/core_ext/blank.rb, line 129 def blank? # The regexp that matches blank strings is expensive. For the case of empty # strings we can speed up this method (~3.5x) with an empty? call. The # penalty for the rest of strings is marginal. empty? || LOCAL_BLANK_RE.match?(self) end
strip_text()
click to toggle source
# File lib/dns_one/core_ext/string.rb, line 6 def strip_text split("\n") .map{|l| l.strip} .join("\n") end
to_a()
click to toggle source
# File lib/dns_one/core_ext/string.rb, line 3 def to_a [self] end