Class: Yamln8tor::Validator
- Inherits:
-
Object
- Object
- Yamln8tor::Validator
- Defined in:
- lib/yamln8tor/validator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#initialize(filename) ⇒ Validator
constructor
A new instance of Validator.
- #validate ⇒ Object
Constructor Details
#initialize(filename) ⇒ Validator
Returns a new instance of Validator.
10 11 12 13 |
# File 'lib/yamln8tor/validator.rb', line 10 def initialize(filename) @filename = filename @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/yamln8tor/validator.rb', line 8 def errors @errors end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/yamln8tor/validator.rb', line 8 def filename @filename end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/yamln8tor/validator.rb', line 15 def validate ym = ::YAML.load read_file ym.ya2yaml(:syck_compatible => true) return true rescue ArgumentError => e error = ::OpenStruct.new(:message => e., :filename => filename) errors << error return false end |