npm package: @geylianlingier/digit-style
Description: Change temperature and other numbers to printable digit styled numbers
Author: Geylian Lingier
Latest version: 0.6.0

# Digit Style

![npm version](https://img.shields.io/npm/v/@geylianlingier/digit-style)
![License](https://img.shields.io/npm/l/@geylianlingier/digit-style)

This library is published to [npm](https://www.npmjs.com/package/@geylianlingier/digit-style)

## Description

This Library converts numbers to printable digit styled strings.

In this library you can find the some classes and interfaces to simply create a nummerical digit display in console.

Eg. If you want to display a temperature more styled in the console.

```text
 ___________________________
|    _     _        _   _   |
|  | _|    _||_|   |_| |    |
|  ||_  /  _|  |       |_   |
|___________________________|
```

For now, this is not fully integrated in the package, but this will be added soon.

You can find next listed classes /interfaces :

If you want more information than given below, check [github pages](https://vives-software-engineering-2020.github.io/examenopdracht-Geylian/)

### * DigitConverter class

* Converts single numbers to instances of the Digit interface.
* Converts full numbers to instances of the Digit interface.
* Converts single characters (one char strings) to instances of the Digit interface.
* Converts full string to instances of the Digit interface.

  !Attention :  The methods in this class converts only known characters and numbers. See table below.

  You can access the single digits also by importing following chars/numbers :

  | existing characters | Digit const | Description |
  |---|---|---|
  | 0, 1, 2,... -9 (also in string '0') | `ZERO`, `ONE`,`TWO`,... | By importing this const you have the instance of the digit interface class for this number. |
  | - | `MINUS` | By importing this const you have the instance of the digit interface class for the minus char. Attention, this character can only give with a number or only as character. |
  | . | `COMMA` | When using full numbers with comma seperated values The same applies as with `MINUS` |
  | ° | `DEGREE` | This character can be used to display a temperature unit. Attention, this can only be used in character or string methods |
  | C | `CHAR_C` | This character can also be used to display a temperature unit. I choose this notation instead of using `Celcius`, so that when I later decide to fully implement the class with all existing characters, I can still do that. The same is true as `DEGREE` |

  These Characters can also be found in the existingDigitCharacters.ts file.

### * Digit (interface)

This interface represents an LED Digit Display. Each Digit consists of 7 controllable segments. (a,b,c,d,e,f,g)

![7-segments](./img/7-segment.jpg)

This is represented in an object on the had of the corresponding letters.

 ![7-segments-6](./img/7-segment-6.png)

  ```json
    {
      a: false,
      b: false,
      c: true,
      d: true,
      e: true,
      f: true,
      g: true
    }
  ```

### * printDigits class

With this class you can print all exisiting characters. (See DigitConverterClass)

```text
     _           _   _       _   _   _   _   _     _   _
 _  | |       |  _|  _| |_| |_  |_    | |_| |_|   |_| |
    |_|  /    | |_   _|   |  _| |_|   | |_|  _|       |_
```

* `toString(digit: Digit[])` method :
  * This method gives you a string where all digits are converted to digit styled in the string.
* `toStringDigits(string: String)` method :
  * This method gives you a string with styled digits from the given string.
* `printDigits(digit: Digit[])` method :
  * This method prints the digits to the console.
* `printStringAsDigits(string: String)` method :
  * This method prints the string as styled digits in the console.

In version v0.3.2 the framework function was added. With this function you can build a framework around the digit styled numbers.

Eg. :

```text
 _____________________________________
|       _   _       _   _     _   _   |
|   _   _| | |      _| | |   |_| |    |
|      |_  |_|  /  |_  |_|       |_   |
|_____________________________________|
```

In version v0.3.3 the large Digits function was added. With this function you can build double sized digits.

```text
 ___________________________________________________________________________________________
|         ___               ___   ___         ___   ___   ___   ___   ___       ___   ___   |
|        |   |           |     |     | |   | |     |         | |   | |   |     |   | |      |
|        |   |           |     |     | |   | |     |         | |   | |   |     |   | |      |
|   ___                     ___   ___   ___   ___   ___         ___   ___       ___         |
|        |   |           | |         |     |     | |   |     | |   |     |           |      |
|        |   |           | |         |     |     | |   |     | |   |     |           |      |
|         ___    /          ___   ___         ___   ___         ___   ___             ___   |
|___________________________________________________________________________________________|
```

### * printTemperatureDigits class

This class has the same functionality as the print digit class. But know you can also insert temperatures and log them into the console.

This class adds a few more methods to set, get and prints the temperature as digits. Also in this class the framework and the large letters works.

## Installation instructions

Make sure youre project is already an npm project:

```bash
npm init
```

To pull this project from npm you can use the next command :

```bash
npm i @geylianlingier/digit-style
```

Update package :

```bash
npm install
```

Running eslinter :

```bash
npm run lint
```

Create/update documentation :

```bash
npm run docs
```

tests :

```bash
npm test
```

## Versions

### v0.0.0

Set up project :

* install all necessary libraries
  * Typescript
  * ts-node
  * jest (tests)

* adding index.ts file with hello world console.log
  * This will be deleted in following versions

### v0.1.0 Digit Converter

Added the Digit Converter class to the project

With this class you can convert numbers and string to digits with the existing digit numbers and characters.

#### v0.1.1 More Documentation

In this version, I added more documentation about the Digit Converter class.

#### v0.1.2 Seperate existing digit numbers

Because all of the numbers/characters are in the same document as the convertDigit class. I decide to seperate all the numbers/characters in a seperated file.

### v0.2.0 NPM publish

add documentation for publishing to npm.

Go to [npm package](https://www.npmjs.com/package/@geylianlingier/digit-style)...

#### v0.2.1

In this version the package will be published for the first time on npm.

### v0.3.0 print digit class

In this version I added the printDigit class. This class prints out the digits styled numbers and characters.

Solve Bug in exisiting digits.

#### v0.3.1 Simplify print digit class

Add more methods to simplify usage of the print class. Know you should not use the digit converter separately to complete the print class.

-> implementation digitConverter in printDigits.

#### v0.3.2 Add framework function

Add framework function to the print digit class. It shows a Framework around the digits.

You can simply enable the framework function in the constructor. ( default value is false)

Or via the 3 new added method :

* `setFramework(framework: boolean)` : set the framework `true` or `false`

* `enableFramework()` : enables Framework

* `disableFramework()` : disables Framework

Extra : better styled chars

#### v0.3.3 Add Large Digit function

Add large digit function to the print class, so it can shows the digits in double size.

You can again simply enable largeLetters, just like you can enable and disable the framework.

### v0.4.0 Print Digit Temperature

Add a new class with the same functionality as the print digit class. But know you can also insert temperatures and log them into the console.

This class adds a few more methods to set, get and prints the temperature as digits. Also in this class the framework and the large letters works.

### v0.5.x Clean up, Documentation, lint, etc

#### v0.5.0 Linter

install eslint and solve linter errors

#### v0.5.1 Documentation

install typedocs and touch

Also added [github pages](https://vives-software-engineering-2020.github.io/examenopdracht-Geylian/) for documentation of the full library.

Also add the LICENSE File.

#### v0.6.0

Add all tests for all classes.

```text
----------------------------|---------|----------|---------|---------|-------------------
File                        | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------------|---------|----------|---------|---------|-------------------
All files                   |     100 |    97.16 |     100 |     100 |
 digitConverter.ts          |     100 |      100 |     100 |     100 |
 existingDigitCharacters.ts |     100 |      100 |     100 |     100 |
 printDigits.ts             |     100 |    98.21 |     100 |     100 | 192,200
 printTemperatureDigits.ts  |     100 |    85.71 |     100 |     100 | 27
----------------------------|---------|----------|---------|---------|-------------------
```

You can also find the coverage in ./coverage folder.

## License

This Library is licenced with MIT.
[More Information](./LICENSE)

## Author

I am Geylian, student Electronics-ICT in university Vives in Bruges.
I create this library for an exam exercise for school.

For more projects like this check my [Github](https://github.com/Geylian) :octocat: