lib/rcap/extensions/string.rb in rcap-2.7.0 vs lib/rcap/extensions/string.rb in rcap-2.7.3
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
class String
CAP_LIST_REGEX = Regexp.new('"([\w\s]+)"|(\S+)')
WHITESPACE_REGEX = Regexp.new('^\s+$')
# Reformats string for a CAP list. If the string contains whitespace it will
@@ -8,10 +10,10 @@
# @return [String]
# @example
# "one".for_cap_list # => "one"
# "two words".for_cap_list # => "\"two words\""
def for_cap_list
- if self =~ /\s/
+ if /\s/.match?(self)
'"' + self + '"'
else
self
end
end