Class: Lab42::Options::Validator

Inherits:
Object
  • Object
show all
Extended by:
Forwarder
Defined in:
lib/lab42/options/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#missingObject (readonly)

Returns the value of attribute missing.



8
9
10
# File 'lib/lab42/options/validator.rb', line 8

def missing
  @missing
end

#spuriousObject (readonly)

Returns the value of attribute spurious.



8
9
10
# File 'lib/lab42/options/validator.rb', line 8

def spurious
  @spurious
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/lab42/options/validator.rb', line 14

def valid?
  missing.empty? && spurious.empty?
end

#validate(parsed) ⇒ Object



18
19
20
21
22
23
# File 'lib/lab42/options/validator.rb', line 18

def validate parsed
  parsed.each do | key, value |
    @spurious.update key => value unless @allowed.include? key
    @missing.delete key if @missing.include? key
  end
end