class Filecop::Rule
Public Class Methods
new(options)
click to toggle source
# File lib/filecop/rule.rb, line 3 def initialize(options) @part = options['part'] @type = options['type'] @pattern = options['pattern'] @caption = options['caption'] @description = options['description'] end
Public Instance Methods
matches?(file)
click to toggle source
# File lib/filecop/rule.rb, line 11 def matches?(file) parts = { path: file, filename: Pathname.new(file).basename, extension: File.extname(file).delete('.') } to_check = parts[@part.to_sym].to_s if @type == 'regex' reg = Regexp.new(@pattern, true) reg.match(to_check) else to_check == @pattern end end
message()
click to toggle source
# File lib/filecop/rule.rb, line 27 def message output = "#{@caption}." output += " #{@description}" if @description output end