Module: UndriveGoogle::Helpers::Parse
- Defined in:
- lib/undrive_google/helpers/parse.rb
Overview
Config Parsing Helpers
Class Method Summary collapse
Class Method Details
.extensions(val) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/undrive_google/helpers/parse.rb', line 9 def extensions(val) if val.is_a?(Array) unknown = val.map(&:to_sym) - DL_FILE_TYPES raise UndriveGoogle::Error, "Unknown extensions: #{unknown}" if unknown.any? val elsif val == "all" DL_FILE_TYPES elsif DL_FILE_TYPES.include?(val.to_sym) [val] else raise UndriveGoogle::Error, "Unknown extensions: #{val}" end end |
.rename_proc(val) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/undrive_google/helpers/parse.rb', line 24 def rename_proc(val) raise UndriveGoogle::Error, "invalid rename pattern #{val}" unless val.length == 2 pattern = Regexp.new(val[0]) replace = val[1] ->(orig) { orig.gsub(pattern, replace) } end |