Class: Kudzu::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/common.rb

Class Method Summary collapse

Class Method Details

.match?(text, pattern) ⇒ Boolean

Returns:

  • (Boolean)

4
5
6
7
8
9
10
11
12
# File 'lib/kudzu/common.rb', line 4

def match?(text, pattern)
  if pattern.is_a?(String)
    File.fnmatch(pattern, text)
  elsif pattern.is_a?(Regexp)
    text =~ pattern
  else
    false
  end
end

.path_to_dir(path) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/kudzu/common.rb', line 14

def path_to_dir(path)
  if path.end_with?('/')
    path
  else
    dir = File.dirname(path)
    dir.end_with?('/') ? dir : dir + '/'
  end
end