パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.3.2

numerus

整数をローマ数字に、ローマ数字の文字列を整数に変換するためのDart拡張機能。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
7.4万
いいね数
18
Pub ポイント
160

パッケージをインストール

flutter pub add numerus

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Numerus は、整数をローマ数字に変換し、逆に変換するための拡張機能を提供する Dart パッケージです。整数型および文字列型に直感的なメソッドを提供することで、ローマ数字表現との作業を簡素化します。教育アプリ、歴史データ処理、またはローマ数字フォーマットが必要なあらゆるアプリケーションに最適です。このパッケージは、Android、iOS、Web、macOS、Windows、Linux などすべての主要プラットフォームをサポートしており、広範な互換性を確保しています。洗練された最小限の構文により、数値変換を扱う際のコードの可読性を高め、ボイラープレートを削減します。

用途

  • 日付をローマ数字に変換する
  • 数体系用の教育アプリ
  • 歴史的文書のデジタル化
  • ローマ数字スタイルで章番号を表示する
  • ローマ数字を使用したゲームスコアの追跡

主な機能

  • 簡単な整数からローマ数字への変換
  • 文字列から整数へのパース
  • Dart 拡張メソッド
  • クロスプラットフォーム対応
  • 最小限のAPI表面
  • 堅牢なエラー処理

適している対象

  • 数学ツールを開発する開発者
  • 教育ソフトウェア
  • 歴史的なテーマを持つアプリ
  • 読みやすい数値形式を必要とするプロジェクト
  • 簡潔な構文を好むユーザー

注意事項

  • 標準的なローマ数字のみを処理します(一般的なルールを超える減算のバリエーションは除く)
  • ローマ数字の制限により、非常に大きな数(>3999)はサポートされていません
  • ローマ字以外の文字セットに対するローカライゼーションサポートなし
  • 無効な入力文字列などのエッジケースに対して手動検証が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

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

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト