Class: YMLValidator::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/yml_validator/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/yml_validator/base.rb', line 7

def initialize file_path
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



3
4
5
# File 'lib/yml_validator/base.rb', line 3

def file_path
  @file_path
end

#file_to_validateObject

Returns the value of attribute file_to_validate.



4
5
6
# File 'lib/yml_validator/base.rb', line 4

def file_to_validate
  @file_to_validate
end

#normalized_fileObject

Returns the value of attribute normalized_file.



5
6
7
# File 'lib/yml_validator/base.rb', line 5

def normalized_file
  @normalized_file
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'lib/yml_validator/base.rb', line 11

def valid?
  begin
    @file_to_validate = YAML.load_file(@file_path)
  rescue Psych::SyntaxError => e
    return false
  end

  validate
end