
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
数値を日本円の表記(例: 12万3,456円)の文字列にフォーマットする helper です。 Active Support の number_to_currency に強く影響を受けています。
$ gem install number_to_yen
require 'number_to_yen'
include NumberToYen
number_to_yen(1234) # => "1,234円"
number_to_yen(123456) # => "12万3,456円"
number_to_yen(123456.0) # => "12万3,456円"
number_to_yen(1234567890) # => "12億3,456万7,890円"
4 桁区切りで 0 が 4 つ続く場合、日本語の慣習に倣ってそれらの桁は省略されます。
number_to_yen(120000) # => "12万円"
number_to_yen(1234560000) # => "12億3,456万円"
number_to_yen(1200007890) # => "12億7,890円"
number_to_yen(1200000000) # => "12億円"
Gemfile に
gem 'number_to_yen'
を追記して bundle install
してください。include などは不要です。View の helper に number_to_yen
が追加されます。
<%= number_to_yen(123456) %> # => "12万3,456円"
Gemfile に次のように指定すると、Integer や Float にインスタンスメソッド to_yen
が生えます。
gem 'number_to_yen', require: 'number_to_yen/core_ext'
1234.to_yen # => "1,234円"
123456.to_yen # => "12万3,456円"
123456.0.to_yen # => "12万3,456円"
1234567890.to_yen # => "12億3,456万7,890円"
より簡潔に書けて便利ですが、helper の number_to_yen
とコア拡張の to_yen
どちらを使うかは個別に判断してください。
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/ttanimichi/number_to_yen
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that number_to_yen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.