Class: Goodcheck::Glob

Inherits:
Object
  • Object
show all
Defined in:
lib/goodcheck/glob.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern:, encoding:) ⇒ Glob

Returns a new instance of Glob.



6
7
8
9
# File 'lib/goodcheck/glob.rb', line 6

def initialize(pattern:, encoding:)
  @pattern = pattern
  @encoding = encoding
end

Instance Attribute Details

#encoding ⇒ Object (readonly)

Returns the value of attribute encoding.



4
5
6
# File 'lib/goodcheck/glob.rb', line 4

def encoding
  @encoding
end

#pattern ⇒ Object (readonly)

Returns the value of attribute pattern.



3
4
5
# File 'lib/goodcheck/glob.rb', line 3

def pattern
  @pattern
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
# File 'lib/goodcheck/glob.rb', line 15

def ==(other)
  other.is_a?(Glob) &&
    other.pattern == pattern &&
    other.encoding == encoding
end

#test(path) ⇒ Object



11
12
13
# File 'lib/goodcheck/glob.rb', line 11

def test(path)
  path.fnmatch?(pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB)
end