Class: ConradFiler::IdType

Inherits:
Object
  • Object
show all
Defined in:
lib/conrad_filer/id_type.rb

Overview

An ID Type describes files in a directory using a regular expression. It is used by a rule to define which file types the rule applies to.

Instance Method Summary collapse

Constructor Details

#initialize(db, a_hash) ⇒ IdType

Returns a new instance of IdType.



8
9
10
# File 'lib/conrad_filer/id_type.rb', line 8

def initialize(db, a_hash)
  @db_rec = a_hash
end

Instance Method Details

#get_regexpObject



24
25
26
27
# File 'lib/conrad_filer/id_type.rb', line 24

def get_regexp
  return @regexp if @regexp != nil
  @regexp = Regexp.new(self.match_regexp, self.ignore_case)
end

#ignore_caseObject



20
21
22
# File 'lib/conrad_filer/id_type.rb', line 20

def ignore_case
  @db_rec['IGNORE_CASE'][0,1].upcase == "T"
end

#match_regexpObject



16
17
18
# File 'lib/conrad_filer/id_type.rb', line 16

def match_regexp
  @db_rec['MATCH_REGEXP']
end

#matches_pathname?(pathname) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/conrad_filer/id_type.rb', line 12

def matches_pathname?(pathname)
  pathname =~ self.get_regexp
end