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
30 31 32 |
# File 'lib/rcap/extensions/string.rb', line 30 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.
12 13 14 15 16 17 18 |
# File 'lib/rcap/extensions/string.rb', line 12 def for_cap_list if self =~ /\s/ '"' + self + '"' else self end end |
#unpack_cap_list ⇒ Array<String>
Will unpack a string generated by Array#to_s_for_cap
26 27 28 |
# File 'lib/rcap/extensions/string.rb', line 26 def unpack_cap_list split(CAP_LIST_REGEX).reject { |match| match == '' || match =~ WHITESPACE_REGEX } end |