Pakete, Repositories und App-Kategorien suchen

Paketdetailsv2.3.2

numerus

Dart-Erweiterungen zum Übersetzen von Ganzzahlen in römische Ziffern und römische Ziffern-Strings in Ganzzahlen.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
74.100
Likes
18
Pub-Punkte
160

Paket installieren

flutter pub add numerus

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Numerus ist ein Dart-Paket, das Erweiterungen für die Umwandlung von Ganzzahlen in römische Ziffern und umgekehrt bereitstellt. Es vereinfacht die Arbeit mit römischen Zahlendarstellungen durch intuitive Methoden direkt auf Integer- und String-Typen. Ideal für Bildungs-Apps, die Verarbeitung historischer Daten oder jede Anwendung, die eine Formatierung römischer Zahlen erfordert. Das Paket unterstützt alle wichtigen Plattformen wie Android, iOS, Web, macOS, Windows und Linux und gewährleistet breite Kompatibilität. Mit sauberer, minimaler Syntax verbessert es die Lesbarkeit des Codes und reduziert Boilerplate beim Umgang mit Zahlenumwandlungen.

Anwendungsfälle

  • Umwandlung von Daten in römische Ziffern
  • Bildungs-Apps für Zahlensysteme
  • Historische Dokumenten-Digitalisierung
  • Kapitelnummern im römischen Stil anzeigen
  • Spiel-Score-Verfolgung mit römischen Ziffern

Hauptmerkmale

  • Einfache Ganzzahl-zu-Römisch-Umwandlung
  • String-zu-Integer-Parsing
  • Dart-Erweiterungsmethoden
  • Plattformübergreifende Unterstützung
  • Minimale API-Oberfläche
  • Robuste Fehlerbehandlung

Geeignet für

  • Entwickler, die Mathetools erstellen
  • Bildungssoftware
  • Apps mit historischen Themen
  • Projekte, die lesbare Zahlformate benötigen
  • Benutzer, die eine knappe Syntax bevorzugen

Hinweise

  • Behandelt nur standardmäßige römische Ziffern (keine subtraktiven Varianten über die gängigen Regeln hinaus)
  • Unterstützt keine sehr großen Zahlen (>3999) aufgrund der Beschränkungen römischer Ziffern
  • Keine Lokalisierungssupport für nicht-lateinische Schriften
  • Benötigt manuelle Überprüfung für Randfälle wie ungültige Eingabestrings

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

Numerus

Dart extensions for translating decimal numbers to Roman numerals and vice versa.

  • Negative numbers are not supported.
  • Functions will return null in place of generating nonsense.
  • Zero can be specified as an option to the RomanNumeralConfig.
  • "Common" Roman numeral format used in modern times (i.e. MDCLXVI) is the default RomanNumeralConfig style. There are other styles: vinculum, apostrophus, and a compact apostrophus that uses single Unicode characters instead of tally marks. See the example below.

Coverage

Examples

import 'package:numerus/numerus.dart';

void main() {
  /// 1) Nice and easy, default config is the "common" config.

  var n = 418;
  print(n.toRomanNumeralString());
  // 'CDXVIII'

  var str = 'CDXVIII';
  print(str.isValidRomanNumeralValue());
  // true
  print(str.toRomanNumeralValue());
  // 418

  /// 2) You can specify other [RomanNumeralConfig]'s to change the style.
  /// You can set the config globally, if you'd like.
  RomanNumerals.romanNumeralsConfig = VinculumRomanNumeralsConfig();

  /// 3) Vinculum config style
  n = 3449671;
  print(n.toRomanNumeralString());
  // M̅M̅M̅C̅D̅X̅L̅MX̅DCLXXI

  str = 'M̅M̅M̅C̅D̅X̅L̅MX̅DCLXXI';
  print(str.isValidRomanNumeralValue());
  // true
  print(str.toRomanNumeralValue());
  // 3449671

  /// 4) You can specify the config inline, too.
  /// 5) Apostrophus style
  n = 2449671;
  print(n.toRomanNumeralString(config: ApostrophusRomanNumeralsConfig()));
  // CCCCIↃↃↃↃCCCCIↃↃↃↃCCCIↃↃↃIↃↃↃↃCCIↃↃIↃↃↃCIↃCCIↃↃIↃCLXXI

  /// 6) ... but frankly, globally set is probably the most common use case
  RomanNumerals.romanNumeralsConfig = ApostrophusRomanNumeralsConfig();

  str = 'CCCCIↃↃↃↃCCCCIↃↃↃↃCCCIↃↃↃIↃↃↃↃCCIↃↃIↃↃↃCIↃCCIↃↃIↃCLXXI';
  print(str.isValidRomanNumeralValue());
  // true
  print(str.toRomanNumeralValue());
  // 2449671

  /// 7) The compact Apostrophus style uses special Unicode characters
  /// just for these symbols.
  RomanNumerals.romanNumeralsConfig = CompactApostrophusRomanNumeralsConfig();
  n = 347449;
  print(n.toRomanNumeralString());
  // ↈↈↈↂↇↁↀↀCCCCXLIX

  // NOTE: if you see missing characters in this example, then you'll need to
  // install a font that supports them.
  str = 'ↈↈↈↂↇↁↀↀCCCCXLIX';
  print(str.isValidRomanNumeralValue());
  // true
  print(str.toRomanNumeralValue());
  // 347449

  /// 8) You can specify a "nulla" (zero placeholder) if you want
  /// to support zero easily.
  RomanNumerals.romanNumeralsConfig = CommonRomanNumeralsConfig(nulla: 'N');
  n = 0;
  print(n.toRomanNumeralString());
  // N

  str = 'N';
  print(str.isValidRomanNumeralValue());
  // true
  print(str.toRomanNumeralValue());
  // 0
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Local development

Set up an environment for local development
  • Install Dart or Flutter
  • Install the coverage tool
    $ dart pub global activate coverage
    
  • Install lcov on your system. e.g. macOS with brew:
    $ brew install lcov
    
Generate code coverage from tests
$ ./bin/coverage-gen
# If you are on macOS and would like the report to immediately
# open, then run the following (not suitable for automation):
$ ./bin/coverage-gen -i

Kategorien

Abhängigkeiten

Abhängigkeiten 1 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden