Class: XRay::FileValidator

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FileValidator

Returns a new instance of FileValidator.



4
5
6
7
# File 'lib/file_validator.rb', line 4

def initialize( options )
  @options = options
  @validators = []
end

Instance Method Details

#add_validator(val) ⇒ Object



9
10
11
# File 'lib/file_validator.rb', line 9

def add_validator( val )
  @validators << val
end

#add_validators(vals) ⇒ Object



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

def add_validators( vals)
  vals.each { |val| add_validator val }
end

#check(file) ⇒ Object Also known as: validate



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/file_validator.rb', line 17

def check( file )
  results = []
  @validators.each do |val|
    if val.respond_to? :check_file
      val_results = val.check_file(file)
      if val_results
        if val_results.is_a? Array
          results.concat val_results
        else
          results << val_results
        end
      end
    end
  end
  results
end