GithubHelp home page GithubHelp logo

abo5 / arabic-wordify Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

Arabic-Wordify is a Ruby gem designed to convert Arabic numbers (integers) into their word equivalents in Arabic, supporting numbers from zero up to a septillion.

License: MIT License

Ruby 100.00%

arabic-wordify's Introduction

arabic-wordify - Arabic Number to Words Converter

arabic-wordify is a Ruby gem that converts Arabic numbers into their word equivalents in Arabic. It supports numbers up to a septillion (1 followed by 24 zeros), including trillions, quadrillions, quintillions, sextillions, and septillions.

Features

  • Comprehensive Number Conversion: Convert any number from 0 up to 10^24 into its Arabic word equivalent.
  • Arabic Digits Support: Automatically converts Arabic digits (٠١٢٣٤٥٦٧٨٩) to English digits before conversion.
  • Error Handling: Properly handles invalid inputs, such as non-integer values or empty inputs.
  • Support for Large Numbers: Includes support for large number names such as million, billion, trillion, and beyond.

Installation

To install arabic-wordify, add this line to your application's Gemfile:

gem 'arabic-wordify'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install arabic-wordify

Usage

Using arabic-wordify in your Ruby application is simple. Here's an example:

require 'arabic-wordify'

number = "٢٢٠٣٤٢٢"

str = ArabicWordify::ArabicNumberWords.convert_to_text(number)
puts str

This will output:

اثنان مليون و مائتان و ثلاثة آلاف و أربعمائة و اثنان و عشرون

Note on Arabic Digits

If you want to input Arabic digits directly without using quotation marks, please note that Ruby does not natively support this. You must input Arabic digits as strings (e.g., "٢٢٠٣٤٢٢"). The arabic-wordify gem will automatically convert these Arabic digits into their English equivalents before processing them.

Error Handling

arabic-wordify will raise an ArabicWordifyError if an invalid input is provided. For example:

begin
  ArabicWordify.convert(nil)
rescue ArabicWordify::ArabicWordifyError => e
  puts e.message
end

This will output:

Failed to convert number to words: Number cannot be nil or empty

Development

To set up your development environment:

  1. Clone the repository:
$ git clone https://github.com/Abo5/arabic-wordify.git
$ cd arabic-wordify
  1. Install dependencies:
$ bundle install
  1. Run tests:
$ bundle exec rspec

Testing

arabic-wordify uses RSpec for testing. All test files are located in the spec/ directory. To run the tests, execute:

$ bundle exec rspec

Example test cases include:

  • Converting various numbers to their word equivalents.
  • Handling invalid inputs and ensuring appropriate errors are raised.

Continuous Integration

arabic-wordify uses GitHub Actions for continuous integration. The configuration file is located at .github/workflows/ruby.yml. It ensures that every push and pull request is automatically tested on the specified Ruby versions.

Contributing

Bug reports and pull requests are welcome on GitHub at arabic-wordify repository. This project is intended to be a safe, welcoming space for collaboration.

License

arabic-wordify is available as open-source under the terms of the MIT License.

Future Plans

  • Internationalization: Extend support to more languages.
  • Additional Number Formats: Support for ordinal numbers and other formats.

Support

If you encounter any issues or have questions, please open an issue on GitHub or contact the maintainers.

Acknowledgements

This project was inspired by the need for a robust Arabic number-to-word converter that supports large numbers and provides accurate results in the Arabic language.# arabic-wordify

arabic-wordify's People

Contributors

abo5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.