# Module: fileStringParsing

Contains all system defined business rules for parsing strings, specific to file names.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 1

### Requires

- module:ruleParsing
- module:loggers
- @haystacks/constants
- path

### Methods

#### (inner) ascertainMatchingFilenames(inputData, inputMetaData) → {boolean}

Compares two file names after stripping off the path and determines if they are matching or not.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The first filename and path that should be used in making the file name comparison.
`inputMetaData` | string | The second filename and path that should be used in making the file name comparison.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 130

##### Returns:

A True or False value to indicate if the file names are equivalent.

Type
  boolean

#### (inner) getFileExtension(inputData, inputMetaData) → {string}

Parses the file name and it may or may not also include the full path, but regardless it gets the file extension of the file.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string that should contain the file name to which we want to get the file extension from.
`inputMetaData` | string | Not sued for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 58

##### Returns:

The file extension such as txt, xml, csv, etc...

Type
  string

#### (inner) getFileNameFromPath(inputData, inputMetaData) → {string}

Gets the file name from a string that contains the path and the file name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string that should have all the folders and path removed from it.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 26

##### Returns:

The file name and file extension string without the full path.

Type
  string

#### (inner) getFirstTopLevelFolderFromPath(inputData, inputMetaData) → {string}

Takes a path and returns the folder at the farthest right of that path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The path that should be evaluated.
`inputMetaData` | string | Not used fore this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 242

##### Returns:

The folder at the far-right of the input path.

Type
  string

#### (inner) removeDotFromFileExtension(inputData, inputMetaData) → {string}

Removes the Dot from the file extension. example: If the input is ".txt", the return value will just be "txt".

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string that should contain the file extension that is being modified.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 82

##### Returns:

The file extension without the dot prefix.

Type
  string

#### (inner) removeFileExtensionFromFileName(inputData, inputMetaData) → {string}

Removes the file extension from the file name if it is there. Otherwise it will remove all the characters after the last period in the file name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The string that should have all the characters after the last period in the file name removed.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 106

##### Returns:

The same input string but without the file extension or all the characters removed after the last dot.

Type
  string

#### (inner) removeXnumberOfFoldersFromEndOfPath(inputData, inputMetaData) → {string}

Removes X number of folders from the end of a path and returns the newly modified path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | The path that should have the number of folders removed.
`inputMetaData` | integer | The number of paths that should be removed from the input path.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 180

##### Returns:

The modified string with the folders removed from the input path.

Type
  string

#### (inner) supportedFileFormatsAre(inputData, inputMetaData) → {string}

Returns a list of supported file formats.

##### Parameters:

Name | Type | Description
--- | --- | ---
`inputData` | string | Not used for this business rule.
`inputMetaData` | string | Not used for this business rule.

Author:
  - Seth Hollingsead
Source:
  - businessRules/rules/stringParsing/fileStringParsing.js, line 160

##### Returns:

A coma separated ist of supported file formats. IE a list of file extensions.

Type
  string