Class: YamlNormalizer::Services::IsYaml

Inherits:
Base
  • Object
show all
Defined in:
lib/yaml_normalizer/services/is_yaml.rb

Overview

IsYaml is a Service Class that provides functionality to check if a file is a parseable non-scalar YAML file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(file) ⇒ IsYaml

Create an IsYaml service object by calling .new and passing a file path String.

Parameters:

  • file (String)

    file path to be regarded



19
20
21
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 19

def initialize(file)
  @file = file.to_s
end

Instance Attribute Details

#fileObject (readonly)

file is the file path String to be regarded



14
15
16
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 14

def file
  @file
end

Instance Method Details

#callObject

Return true if given file is a valid YAML file



24
25
26
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 24

def call
  file? && parseable? && !scalar?
end