Sha256: 19ba53466fee1a6c086cbe0e417bd9cace350c6b1ee3b7428a9cf08b5f1bd707
Contents?: true
Size: 640 Bytes
Versions: 10
Compression:
Stored size: 640 Bytes
Contents
module OptParseValidator # Implementation of the FilePath Option class OptFilePath < OptPath # @param [ Array ] option See OptBase#new # @param [ Hash ] attrs See OptPath#new # :extensions [ Array | String ] The allowed extension(s) def initialize(option, attrs = {}) super(option, attrs) @attrs.merge!(file: true) end def allowed_attrs # :extensions is put at the first place [:extensions] + super end def check_extensions(path) return if [*attrs[:extensions]].include?(path.extname.delete('.')) fail "The extension of '#{path}' is not allowed" end end end
Version data entries
10 entries across 10 versions & 1 rubygems