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: Canonical, Range, Sections Classes: Checker, Events, Logger, Penalties, Placings, Raws, Subdivisions, Teams, TopLevel, Tournament

Instance Method Summary collapse

Constructor Details

#initialize(loglevel: Logger::WARN, canonical: true) ⇒ Validator

Returns a new instance of Validator.



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

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

Instance Method Details

#last_logObject



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

def last_log
  @logger.log
end

#valid?(rep_or_yaml) ⇒ Boolean

Returns:

  • (Boolean)


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

def valid?(rep_or_yaml)
  @logger.flush

  if rep_or_yaml.instance_of? String
    valid_yaml?(rep_or_yaml, @logger)
  else
    valid_rep?(rep_or_yaml, @logger)
  end
end