Class: Lutaml::Xml::Schema::Xsd::FileValidationResult
- Inherits:
-
Object
- Object
- Lutaml::Xml::Schema::Xsd::FileValidationResult
- Defined in:
- lib/lutaml/xml/schema/xsd/file_validation_result.rb
Overview
Value object representing the validation result for a single file
Instance Attribute Summary collapse
-
#detected_version ⇒ Object
readonly
Returns the value of attribute detected_version.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
True if the file failed validation.
-
#initialize(file:, valid:, error: nil, detected_version: nil) ⇒ FileValidationResult
constructor
A new instance of FileValidationResult.
-
#success? ⇒ Boolean
True if the file passed validation.
-
#to_h ⇒ Hash
Convert to hash for backward compatibility.
-
#to_s ⇒ String
Human-readable string representation.
Constructor Details
#initialize(file:, valid:, error: nil, detected_version: nil) ⇒ FileValidationResult
Returns a new instance of FileValidationResult.
15 16 17 18 19 20 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 15 def initialize(file:, valid:, error: nil, detected_version: nil) @file = file @valid = valid @error = error @detected_version = detected_version end |
Instance Attribute Details
#detected_version ⇒ Object (readonly)
Returns the value of attribute detected_version.
9 10 11 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 9 def detected_version @detected_version end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 9 def error @error end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 9 def file @file end |
Instance Method Details
#failure? ⇒ Boolean
Returns true if the file failed validation.
28 29 30 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 28 def failure? !success? end |
#success? ⇒ Boolean
Returns true if the file passed validation.
23 24 25 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 23 def success? @valid end |
#to_h ⇒ Hash
Convert to hash for backward compatibility
34 35 36 37 38 39 40 41 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 34 def to_h { file: file, valid: success?, error: error, detected_version: detected_version, }.compact end |
#to_s ⇒ String
Returns Human-readable string representation.
44 45 46 47 48 49 50 |
# File 'lib/lutaml/xml/schema/xsd/file_validation_result.rb', line 44 def to_s if success? "#{file}: VALID" else "#{file}: INVALID - #{error}" end end |