Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rcap/extensions/string.rb
Constant Summary
- CAP_LIST_REGEX =
Regexp.new( '"([\w\s]+)"|(\S+)' )
- WHITESPACE_REGEX =
Regexp.new('^\s+$')
Instance Method Summary (collapse)
-
- (String) for_cap_list
Reformats string for a CAP list.
-
- (Array<String>) unpack_cap_list
Will unpack a string generated by Array#to_s_for_cap.
Instance Method Details
- (String) for_cap_list
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 |
- (Array<String>) unpack_cap_list
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 self.split( CAP_LIST_REGEX ).reject{ |match| match == "" || match =~ WHITESPACE_REGEX } end |