Class: CDONFeedValidator::Validator
- Inherits:
-
Object
- Object
- CDONFeedValidator::Validator
- Defined in:
- lib/cdon_feed_validator/validator.rb
Direct Known Subclasses
Constant Summary collapse
- XSDDIR =
File.('../xsd', __dir__)
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(xml, **options) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(xml, **options) ⇒ Validator
Returns a new instance of Validator.
9 10 11 12 13 |
# File 'lib/cdon_feed_validator/validator.rb', line 9 def initialize(xml, **) @xml = Nokogiri::XML xml @options = .as_json @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/cdon_feed_validator/validator.rb', line 7 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/cdon_feed_validator/validator.rb', line 7 def @options end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
7 8 9 |
# File 'lib/cdon_feed_validator/validator.rb', line 7 def xml @xml end |
Instance Method Details
#valid? ⇒ Boolean
15 16 17 18 |
# File 'lib/cdon_feed_validator/validator.rb', line 15 def valid? validate errors.empty? end |
#validate ⇒ Object
20 21 22 23 24 |
# File 'lib/cdon_feed_validator/validator.rb', line 20 def validate @errors = file .validate(xml) .map(&:to_s) || [] end |