Sha256: 0fd7c4a7778a81e982081eeee30f739103cb3b584e5904884c282c84958a6fb7
Contents?: true
Size: 647 Bytes
Versions: 12
Compression:
Stored size: 647 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 Error, "The extension of '#{path}' is not allowed" end end end
Version data entries
12 entries across 12 versions & 1 rubygems