Module: RubyTube::Utils

Defined in:
lib/rubytube/utils.rb

Class Method Summary collapse

Class Method Details

.regex_search(pattern, string, group) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/rubytube/utils.rb', line 5

def regex_search(pattern, string, group)
  match = string.match(pattern)
  if match
    return match[group]
  end
  nil
end

.target_directory(output_path = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rubytube/utils.rb', line 13

def target_directory(output_path = nil)
  if output_path
    result = File.join(Dir.pwd, output_path) unless File.absolute_path?(output_path)
  else
    result = Dir.pwd
  end

  FileUtils.mkdir_p(result) unless Dir.exist?(result)
  result
end