Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rcap/extensions/string.rb
Constant Summary collapse
- CAP_LIST_REGEX =
Regexp.new('"([\w\s]+)"|(\S+)')
- WHITESPACE_REGEX =
Regexp.new('^\s+$')
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#for_cap_list ⇒ String
Reformats string for a CAP list.
-
#unpack_cap_list ⇒ Array<String>
Will unpack a string generated by Array#to_s_for_cap.
Instance Method Details
#blank? ⇒ Boolean
32 33 34 |
# File 'lib/rcap/extensions/string.rb', line 32 def blank? empty? end |
#for_cap_list ⇒ String
Reformats string for a CAP list. If the string contains whitespace it will enclose the contents in quotation marks.
14 15 16 17 18 19 20 |
# File 'lib/rcap/extensions/string.rb', line 14 def for_cap_list if /\s/.match?(self) '"' + self + '"' else self end end |
#unpack_cap_list ⇒ Array<String>
Will unpack a string generated by Array#to_s_for_cap
28 29 30 |
# File 'lib/rcap/extensions/string.rb', line 28 def unpack_cap_list split(CAP_LIST_REGEX).reject { |match| match == '' || match =~ WHITESPACE_REGEX } end |