Class: YamlNormalizer::Services::IsYaml

Inherits:
Base
  • Object
show all
Includes:
Helpers::Normalize
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 included from Helpers::Normalize

#normalize_yaml

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



21
22
23
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 21

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

Instance Attribute Details

#fileObject (readonly)

file is the file path String to be regarded



16
17
18
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 16

def file
  @file
end

Instance Method Details

#callObject

Return true if given file is a valid YAML file



26
27
28
# File 'lib/yaml_normalizer/services/is_yaml.rb', line 26

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