Words to Numbers API - Ruby Gem

Words to Numbers is a simple tool for converting words to numbers. It returns the words in numbers.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_wordstonumbers'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_wordstonumbers

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_wordstonumbers'

# Initialize the client
client = APIVerve::Wordstonumbers::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ words: "seven thousand six hundred and twenty" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ words: "seven thousand six hundred and twenty" })
  puts response["data"]
rescue APIVerve::Wordstonumbers::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Wordstonumbers::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Wordstonumbers::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "number": "7620",
    "words": "seven thousand, six hundred twenty",
    "ordinal": "seven thousand, six hundred twentieth",
    "numberOfDigits_numeric": 4,
    "numberOfDigits_words": "four",
    "eachNumber": [
      "seven",
      "six",
      "two",
      "zero"
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.