lib/rcap/extensions/string.rb in rcap-2.4.1 vs lib/rcap/extensions/string.rb in rcap-2.5.0
- old
+ new
@@ -1,7 +1,7 @@
class String
- CAP_LIST_REGEX = Regexp.new( '"([\w\s]+)"|(\S+)' )
+ 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
# enclose the contents in quotation marks.
#
@@ -9,11 +9,11 @@
# @example
# "one".for_cap_list # => "one"
# "two words".for_cap_list # => "\"two words\""
def for_cap_list
if self =~ /\s/
- '"'+self+'"'
+ '"' + self + '"'
else
self
end
end
@@ -22,10 +22,10 @@
# @return [Array<String>]
# @example
# "one \"two words\" three".unpack_cap_list # => [ "one", "two words", "three" ]
# @see Array#to_s_for_cap
def unpack_cap_list
- self.split( CAP_LIST_REGEX ).reject{ |match| match == "" || match =~ WHITESPACE_REGEX }
+ split(CAP_LIST_REGEX).reject { |match| match == '' || match =~ WHITESPACE_REGEX }
end
def blank?
empty?
end