Words to Numbers converts spelled-out number phrases into numeric digits. Pass written words to receive the calculated number, formatted English notation, and total digit counts.
Add this line to your application's Gemfile:
gem 'apiverve_wordstonumbers'And then execute:
$ bundle installOr install it yourself as:
$ gem install apiverve_wordstonumbersGet your API key at APIVerve
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 responsebegin
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# Enable debug logging
client = APIVerve::Wordstonumbers::Client.new(
api_key: "YOUR_API_KEY",
debug: true
){
"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"
]
}
}For more information, visit the API Documentation.
- Website: https://apiverve.com/marketplace/wordstonumbers?utm_source=ruby&utm_medium=referral&utm_content=readme
- Email: hello@apiverve.com
This gem is available under the MIT License.