Class: ExtensionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/filters/extension_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_class, extension) ⇒ ExtensionFilter

Returns a new instance of ExtensionFilter.



3
4
5
6
# File 'lib/filters/extension_filter.rb', line 3

def initialize(file_class, extension)
  @file_class = file_class
  @extension = extension.downcase
end

Instance Method Details

#completeObject



17
18
# File 'lib/filters/extension_filter.rb', line 17

def complete
end

#file_type(file_name) ⇒ Object

Return the part of the file name string after the last ‘.’



13
14
15
# File 'lib/filters/extension_filter.rb', line 13

def file_type(file_name)
  @file_class.extname(file_name).gsub( /^\./, '' ).downcase 
end

#filter(file_name) ⇒ Object



8
9
10
# File 'lib/filters/extension_filter.rb', line 8

def filter(file_name)
  return file_type(file_name) == @extension
end