Class: SciolyFF::Validator

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

Overview

Checks if SciolyFF YAML files and/or representations (i.e. hashes that can be directly converted to YAML) comply with spec (i.e. safe for interpreting)

Defined Under Namespace

Modules: Sections Classes: Checker, Events, Logger, Penalties, Placings, Raws, Teams, TopLevel, Tournament

Instance Method Summary collapse

Constructor Details

#initialize(loglevel = Logger::WARN) ⇒ Validator

Returns a new instance of Validator.



19
20
21
22
# File 'lib/sciolyff/validator.rb', line 19

def initialize(loglevel = Logger::WARN)
  @logger = Logger.new loglevel
  @checkers = {}
end

Instance Method Details

#last_logObject



34
35
36
# File 'lib/sciolyff/validator.rb', line 34

def last_log
  @logger.log
end

#valid?(rep_or_file) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'lib/sciolyff/validator.rb', line 24

def valid?(rep_or_file)
  @logger.flush

  if rep_or_file.instance_of? String
    valid_file?(rep_or_file, @logger)
  else
    valid_rep?(rep_or_file, @logger)
  end
end